sendEmailMessage()
Immediately sends up to 10 draft email messages.
For Enterprise SOAP:
For Partner SOAP:
Use this call with Lightning Platform AppExchange applications, custom applications, or other applications outside of Salesforce to send up to 10 draft email messages. The messages can include all standard email attributes (such as subject line and blind carbon copy address), use Salesforce email templates, and be in plain text or HTML format. You can use Salesforce to track the status of HTML email, including the date the email was sent, first opened, last opened, and the total number of times it was opened. (See Tracking HTML Email in the Salesforce Help for more information.)
The email address of the logged-in user is inserted in the From Address field of the email header. All return email and out-of-office replies go to the logged-in user. If bounce management is enabled and SingleEmailMessage.targetObjectId or MassEmailMessage.targetObjectIds is set, bounces are processed by Salesforce automatically, and the appropriate records are updated; otherwise, they go to the logged-in user. Bounce management works for contacts and leads only.
- Email messages sent with this call count against the sending organization’s daily single email limit. When this limit is reached,
sendEmailMessage()calls using SingleEmailMessage are rejected, and the user receives aSINGLE_EMAIL_LIMIT_EXCEEDEDerror code. However, single emails sent through the application are allowed. - Mass email messages sent with this call count against the sending organization’s daily mass email limit. When this limit is reached,
sendEmail()calls using MassEmailMessage are rejected, and the user receives aMASS_MAIL_LIMIT_EXCEEDEDerror code. - The
AllOrNoneheader is not honored by this call.sendEmailMessage()returns partial success even if theAllOrNoneheader is set totrue.
This sample creates a case and a draft email message, and sets the message fields, including the From, To, CC, and BCC recipients, subject, and body text. It also creates an attachment and sends the email message with the attachment. Finally, it writes a status message or an error message, if any, to the console.
None.
BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED
BCC_SELF_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED
EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR