0

I have below emailing code where I need to send mail in Callibri font. Can someone let me know a wayout here?

Code:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

Messaging.SingleEmailMessage mailDM = new Messaging.SingleEmailMessage();
sendTo.add(OneMap.get(mycontact.ID).RepEmail_abv__c); 
mail.setToAddresses(sendTo);
sendToDM.add(OneMap.get(mycontact.ID).ManagerEmail_abv__c);
mailDM.setToAddresses(sendToDM);
mail.setSenderDisplayName('Abbvie IT Team');
mail.SetSaveAsActivity(false);
mailDM.setSenderDisplayName('Abbvie IT Team');
mailDM.SetSaveAsActivity(false);
ccTo.add(OneMap.get(mycontact.ID).ManagerEmail_abv__c);
mail.setCcAddresses(ccTo);

mail.setTargetObjectId(OneMap.get(mycontact.ID).Rep_abv__c);
mailDM.setTargetObjectId(OneMap.get(mycontact.ID).Rep_abv__r.ManagerID);
mail.setSubject('Attention Required:  NEW ABS incident in iREP');
mailDM.setSubject('Action Required: NEW ABS incident in iREP');
String body = 'Dear ' + OneMap.get(mycontact.ID).Rep_abv__r.Name + ', ';
body += '<br><br>What you need to know:';
body += '<br>New ABS Incidents have been generated in iREP. Please review these incidents with your DM or Applicable Manager. There is no other action for you to complete in iREP.';
body += '<br>To view your open incidents:<br>';
body += '•       Log into the iREP app on your iPad and select “Compliance Incidents”<br>';
body += '•       Select the “Open Incidents” View in the Compliance Incidents Home Page.<br>';
body += '•       Click the Incident ID to view your incidents If you need assistance, please call the Field Help Desk at 1-800-344-6776.<br>';

String bodyDM = 'Dear ' +  OneMap.get(mycontact.ID).Rep_abv__r.Manager.Name + ', ';
bodyDM += '<br><br>What you need to know:';
bodyDM += '<br>New ABS Incident(s) have been published in iREP.';
bodyDM += '<br>What you need to do:';
bodyDM += '<br>•       Review the incident(s)';
bodyDM += '<br>•       Coach your representative';
bodyDM += '<br>•       Attest to the incident, submit, and sync iREP within two weeks, per ABS policy';
bodyDM += '<br>If you need assistance, please call the Field Help Desk at 1-800-344-6776.';

mail.setHtmlBody(body);
mails.add(mail);
mailDM.setHtmlBody(bodyDM);
mailsDM.add(mailDM);
system.debug('@mails@'+mails);

}
// Step 6: Send all emails in the master list*/
Messaging.sendEmail(mails);
Messaging.sendEmail(mailsDM);
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Successfully Published'));
1

Modify the construction of the body of your email and enclose the entire message within the paragraph tags:

<p style="font-family:Calibri"> [your email body here]</p>.

Apex code:

  body = '<p style="font-family:Calibri">' + body + '</p>';

You may also want to checkout the HTML and CSS tutorials at W3Schools.com

  • Can I put string mail body in your tag above as [mail body]? – Testing_SFDC Sep 13 '15 at 16:30
  • [your email body here] is meant to indicate where you would put your email body. You still need to use apex to do the string contatentation to build the email body – Developer Wonk Sep 13 '15 at 16:35
  • mail.setHtmlBody(<p style="font-family:Calibri"> body</p>); I am getting error by putting it like this. Can you please help? – Testing_SFDC Sep 14 '15 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.