SingleEmailMessage Methods
Namespace
Usage
All base email (Email class) methods are also available to the SingleEmailMessage objects.
SingleEmailMessage Constructors
The following are constructors for SingleEmailMessage.
- SingleEmailMessage()
Creates a new instance of the Messaging.SingleEmailMessage class.
SingleEmailMessage Methods
The following are methods for SingleEmailMessage. All are instance methods.
- setBccAddresses(String[])
Optional. A list of blind carbon copy (BCC) addresses. The maximum allowed is 25. This argument is allowed only when a template is not used. - setCcAddresses(String[])
Optional. A list of carbon copy (CC) addresses. The maximum allowed is 25. This argument is allowed only when a template is not used. - setCharset(String)
Optional. The character set for the email. If this value is null, the user's default value is used. - setDocumentAttachments(ID[])
Optional. A list containing the ID of each document object you want to attach to the email. - setFileAttachments(EmailFileAttachment[])
Optional. A list containing the file names of the binary and text files you want to attach to the email. - setHtmlBody(String)
Optional. The HTML version of the email, specified by the sender. The value is encoded according to the specification associated with the organization. You must specify a value for setTemplateId, setHtmlBody, or setPlainTextBody. Or, you can define both setHtmlBody and setPlainTextBody. - setInReplyTo(String)
Optional. The In-Reply-To field of the outgoing email. Identifies the email or emails to which this one is a reply (parent emails). Contains the parent email or emails' message-IDs. - setPlainTextBody(String)
Optional. The text version of the email, specified by the sender. You must specify a value for setTemplateId, setHtmlBody, or setPlainTextBody. Or, you can define both setHtmlBody and setPlainTextBody. - setOrgWideEmailAddressId(ID)
Optional. The ID of the organization-wide email address associated with the outgoing email. The object's DisplayName field cannot be set if the setSenderDisplayNamefield is already set. - setReferences(String)
Optional. The References field of the outgoing email. Identifies an email thread. Contains the parent emails' References and message IDs, and possibly the In-Reply-To fields. - setSubject(String)
Optional. The email subject line. If you are using an email template, the subject line of the template overrides this value. - setTargetObjectId(ID)
Required if using a template, optional otherwise. The ID of the contact, lead, or user to which the email will be sent. The ID you specify sets the context and ensures that merge fields in the template contain the correct data. - setToAddresses(String[])
Optional. A list of email addresses to which you are sending the email. The maximum number of email addresses allowed is 100. This argument is allowed only when a template is not used. - setWhatId(ID)
Optional. If you specify a contact for the targetObjectId field, you can specify a whatId as well. This helps to further ensure that merge fields in the template contain the correct data.
setBccAddresses(String[])
Signature
public Void setBccAddresses(String[] bccAddresses)
Parameters
- bccAddresses
- Type: String[]
Return Value
Type: Void
Usage
At least one value must be specified in one of the following fields: toAddresses, ccAddresses, bccAddresses, targetObjectId, or targetObjectIds.
If the BCC compliance option is set at the organization level, the user cannot add BCC addresses on standard messages. The following error code is returned:BCC_NOT_ALLOWED_IF_BCC_ COMPLIANCE_ENABLED. Contact your salesforce.com representative for information on BCC compliance.
setCcAddresses(String[])
Signature
public Void setCcAddresses(String[] ccAddresses)
Parameters
- ccAddresses
- Type: String[]
Return Value
Type: Void
Usage
- toAddresses
- ccAddresses
- bccAddresses
- targetObjectId
- targetObjectIds
setCharset(String)
Signature
public Void setCharset(String charset)
Parameters
- charset
- Type: String
Return Value
Type: Void
setDocumentAttachments(ID[])
Signature
public Void setDocumentAttachments(ID[] docAttachments)
Parameters
- docAttachments
- Type: ID[]
Return Value
Type: Void
Usage
You can attach multiple documents as long as the total size of all attachments does not exceed 10 MB.
setFileAttachments(EmailFileAttachment[])
Signature
public Void setFileAttachments(EmailFileAttachment[] fileAttachments)
Parameters
- fileAttachments
- Type: Messaging.EmailFileAttachment[]
Return Value
Type: Void
Usage
You can attach multiple files as long as the total size of all attachments does not exceed 10 MB.
setHtmlBody(String)
Signature
public Void setHtmlBody(String htmlBody)
Parameters
- htmlBody
- Type: String
Return Value
Type: Void
setInReplyTo(String)
Signature
public Void setInReplyTo(String inReplyTo)
Parameters
- inReplyTo
- Type: String
Return Value
Type: Void
setPlainTextBody(String)
Signature
public Void setPlainTextBody(String plainTextBody)
Parameters
- plainTextBody
- Type: String
Return Value
Type: Void
setOrgWideEmailAddressId(ID)
Signature
public Void setOrgWideEmailAddressId(ID emailAddressId)
Parameters
- emailAddressId
- Type: ID
Return Value
Type: Void
setReferences(String)
Signature
public Void setReferences(String references)
Parameters
- references
- Type: String
Return Value
Type: Void
setSubject(String)
Signature
public Void setSubject(String subject)
Parameters
- subject
- Type: String
Return Value
Type: Void
setTargetObjectId(ID)
Signature
public Void setTargetObjectId(ID targetObjectId)
Parameters
- targetObjectId
- Type: ID
Return Value
Type: Void
setToAddresses(String[])
Signature
public Void setToAddresses(String[] toAddresses)
Parameters
- toAddresses
- Type: String[]
Return Value
Type: Void
Usage
- toAddresses
- ccAddresses
- bccAddresses
- targetObjectId
- targetObjectIds
setWhatId(ID)
Signature
public Void setWhatId(ID whatId)
Parameters
- whatId
- Type: ID
Return Value
Type: Void
Usage
The value must be one of the following types:
- Account
- Asset
- Campaign
- Case
- Contract
- Opportunity
- Order
- Product
- Solution
- Custom
Various trademarks held by their respective owners.
No comments:
Post a Comment