Ajax (1) Apex Class (12) Apex Trigger (2) Community (2) Home Page (1) HTML (4) Integration (3) JS (7) KB (1) Label (1) Licenses (1) Listing (1) Log (1) OOPs (5) Sharing (1) Static Resource (1) Test Class (3) URI (1) Visualforce (10)

Tuesday 8 April 2014

SingleEmailMessage Methods

Open topic with navigation

SingleEmailMessage Methods

Contains methods for sending single email messages.

Namespace

Messaging

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.

Signature

public SingleEmailMessage()

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 setTemplateIdsetHtmlBody, 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 setTemplateIdsetHtmlBody, 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[])

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.

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: toAddressesccAddressesbccAddressestargetObjectId, 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[])

Optional. A list of carbon copy (CC) addresses. The maximum allowed is 25. This argument is allowed only when a template is not used.

Signature

public Void setCcAddresses(String[] ccAddresses)

Parameters

ccAddresses
Type: String[]

Return Value

Type: Void

Usage

All email must have a recipient value of at least one of the following:
  • toAddresses
  • ccAddresses
  • bccAddresses
  • targetObjectId
  • targetObjectIds

setCharset(String)

Optional. The character set for the email. If this value is null, the user's default value is used.

Signature

public Void setCharset(String charset)

Parameters

charset
Type: String

Return Value

Type: Void

setDocumentAttachments(ID[])

Optional. A list containing the ID of each document object you want to attach to the email.

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[])

Optional. A list containing the file names of the binary and text files you want to attach to the email.

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)

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 forsetTemplateIdsetHtmlBody, or setPlainTextBody. Or, you can define both setHtmlBody and setPlainTextBody.

Signature

public Void setHtmlBody(String htmlBody)

Parameters

htmlBody
Type: String

Return Value

Type: Void

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.

Signature

public Void setInReplyTo(String inReplyTo)

Parameters

inReplyTo
Type: String

Return Value

Type: Void

setPlainTextBody(String)

Optional. The text version of the email, specified by the sender. You must specify a value for setTemplateIdsetHtmlBody, or setPlainTextBody. Or, you can define bothsetHtmlBody and setPlainTextBody.

Signature

public Void setPlainTextBody(String plainTextBody)

Parameters

plainTextBody
Type: String

Return Value

Type: Void

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 setSenderDisplayName field is already set.

Signature

public Void setOrgWideEmailAddressId(ID emailAddressId)

Parameters

emailAddressId
Type: ID

Return Value

Type: Void

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.

Signature

public Void setReferences(String references)

Parameters

references
Type: String

Return Value

Type: Void

setSubject(String)

Optional. The email subject line. If you are using an email template, the subject line of the template overrides this value.

Signature

public Void setSubject(String subject)

Parameters

subject
Type: String

Return Value

Type: Void

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.

Signature

public Void setTargetObjectId(ID targetObjectId)

Parameters

targetObjectId
Type: ID

Return Value

Type: Void

Usage

Do not specify the IDs of records that have the Email Opt Out option selected.

All email must have a recipient value of at least one of the following:
  • toAddresses
  • ccAddresses
  • bccAddresses
  • targetObjectId
  • targetObjectIds

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.

Signature

public Void setToAddresses(String[] toAddresses)

Parameters

toAddresses
Type: String[]

Return Value

Type: Void

Usage

All email must have a recipient value of at least one of the following:
  • toAddresses
  • ccAddresses
  • bccAddresses
  • targetObjectId
  • targetObjectIds

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.

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
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.

 

No comments:

Post a Comment