Print this page

Send email options for DML operations carried out in Apex code.​

Knowledge Article Number 000006605
Description

DmlOptions Email handler class can be used to set email options for the dml operations performed in the apex code.

Resolution

Even though auto-sent emails can be triggered by actions in the Salesforce user interface, the DMLOptions settings foremailHeader take effect only for DML operations carried out in Apex code.

This behavior can be controlled using the DMLOptions class during execution.  Here is an example of how this can be done.

Database.DMLOptions dlo = new Database.DMLOptions();
dlo.emailHeader.triggerUserEmail = true;

database.insert(tasksToCreateList,dlo);

The following are properties for DmlOptions.EmailHeader.

  • triggerAutoResponseEmail : Indicates whether to trigger auto-response rules (true) or not (false), for leads and cases.
  • triggerOtherEmail : Indicates whether to trigger email outside the organization (true) or not (false).
  • triggerUserEmail : Indicates whether to trigger email that is sent to users in the organization (true) or not (false).

For more information on DMLOptions, please see the following document:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_dmloptions.htm?SearchType=Stem&Highlight=DMLOptions





promote demote