Solution
- Create an appropriate email template through the email template wizard. Salesforce.com supports multiple email template types. This examples assumes you are using a Visualforce email template. To create a Visualforce email template, you must have the "Customize Application" permission enabled.
- Send an automatic email response to the job applicant's incoming email using the Messaging.sendEmail static method to process outbound email messages.
- Click Setup | Email | My Templates. If you have permission to edit public templates, click Setup | Communication Templates | Email Templates.
- Click New Template.
- Choose Visualforce and click Next.
- Choose a folder in which to store the template.
- Select the Available For Use checkbox if you would like this template offered to users when sending an email.
- Enter an Email Template Name.
- If necessary, change the Template Unique Label.
- Select an Encoding setting to determine the character set for the template.
- Enter a Description of the template. Both template name and description are for your internal use only.
- Enter the subject line for your template in Email Subject.
- In the Recipient Type drop-down list, select the type of recipient that will receive the email template.
- Optionally, in the Related To Type drop-down list, select the object from which the template will retrieve merge field data.
- Click Save.
- Click Edit Template.
- Enter markup text for your Visualforce email template.
- Click Save to save your changes and view the details of the template, or click Quick Save to save your changes and continue editing your template. Your Visualforce markup must be valid before you can save your template. The maximum size of a Visualforce email template cannot exceed 1 MB.
This sample Visualforce email template creates an interview invitation:
<messaging:emailTemplate subject="Received your resume" recipientType="Contact" relatedToType="Job_Application__c"> <messaging:plainTextEmailBody > Dear {!relatedTo.Candidate__r.First_Name__c} {!relatedTo.Candidate__r.Last_Name__c} Thank you for your interest in the position {!relatedto.Position__r.name} We would like to invite you for an interview. Please respond to the attached invitation. Regards, Company </messaging:plainTextEmailBody> <messaging:attachment filename="meeting.ics" renderAs="text/calendar; charset=UTF-8; method=REQUEST"> BEGIN:VCALENDAR METHOD:REQUEST BEGIN:VTIMEZONE TZID:(GMT-08.00) Pacific Time (US and Canada) BEGIN:STANDARD DTSTART:16010101T020000 TZOFFSETFROM:-0700 TZOFFSETTO:-0800 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU END:STANDARD BEGIN:DAYLIGHT DTSTART:16010101T020000 TZOFFSETFROM:-0800 TZOFFSETTO:-0700 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU END:DAYLIGHT END:VTIMEZONE BEGIN:VEVENT DTSTAMP:20090921T202219Z DTSTART;TZID="(GMT-08.00) Pacific Time (US and Canada)":20090923T140000 SUMMARY:Invitation: Interview Schedule @ Wed Sep 23 2pm - 4pm ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE; CN="{!recipient.name}":MAILTO:{!recipient.email} ORGANIZER;CN="John.Smith":MAILTO:recruiter@company.com LOCATION:Hawaii DTEND;TZID="(GMT-08.00) Pacific Time (US and Canada)":20090923T160000 DESCRIPTION: You are invited to an inverview \NInterview Schedule \NWed Sep 23 2pm - 4pm (Timezone: Pacific Time) \NCalendar: John Smith \N\NOwner/Creator: recruiter@company.com \NYou will be meeting with these people: CEO Bill Jones, Office Manager Jane Jones \N SEQUENCE:0 PRIORITY:5 STATUS:CONFIRMED END:VEVENT END:VCALENDAR </messaging:attachment> </messaging:emailTemplate>
Then, send an automatic email response to the job applicant's incoming email. This example uses a Visualforce email template:
// In a separate class so that it can be used elsewhere Global class emailHelper { public static void sendEmail(ID recipient, ID candidate) { //New instance of a single email message Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // Who you are sending the email to mail.setTargetObjectId(recipient); // The email template ID used for the email mail.setTemplateId('00X30000001GLJj'); mail.setWhatId(candidate); mail.setBccSender(false); mail.setUseSignature(false); mail.setReplyTo('recruiting@acme.com'); mail.setSenderDisplayName('HR Recruiting'); mail.setSaveAsActivity(false); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }
Source : http://developer.force.com/cookbook/recipe/creating-email-templates-and-automatically-sending-emails
https://login.salesforce.com/help/doc/en/creating_visualforce_email_templates.htm
No comments:
Post a Comment