4

I am using Apex SingleEmailMessage to send out an email message, and utilizing the setOrgWideEmailAddressId to make sure this e-mail appears coming from a company e-mail and not from a specific user.

If users have a personal signature set up, the signature gets appended to the bottom of the e-mail message. How to avoid this personal signature?

Apex code that send email message:

 public static void sendEmail(String subject,String body, String address, String ccAddress) {

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {address};
        mail.setToAddresses(toAddresses);
    if(ccAddress!=null) {
        String[] ccAddresses = new String[] {ccAddress};
            mail.setCcAddresses(ccAddresses);
    }
    mail.setSubject(subject);
    mail.setPlainTextBody(body);

    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'my@company.com'];
    if ( owea.size() > 0 ) {
        mail.setOrgWideEmailAddressId(owea.get(0).Id);
    }
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}
  • Which users are you referring here who have personal signature? Where is that signature, is that on the email template you are using? – Jayant Das May 2 '18 at 2:49
  • We have set up signature here for users. help.salesforce.com/articleView?id=000001133&type=1 – Kritik May 2 '18 at 2:55
  • What is in your email template and type of the template that you are using will help here. – Jayant Das May 2 '18 at 2:57
  • We are not using email template. – Kritik May 2 '18 at 3:05
6

SingleEmailMessage extends Email class and inherits all its method. Refer to below excerpt from the documentation.

SingleEmailMessage extends Email and inherits all of its methods. All base email (Email class) methods are also available to the SingleEmailMessage objects.

To stop sending signature as part of the email, you need to use the following method from the base Email class:

mail.setUseSignature(false);

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.