I wanted to send an email from my Apex class, and I used the following code:
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.toAddresses = new String[] { emailId };
message.optOutPolicy = 'FILTER';
message.setSenderDisplayName(senderDisplay);
message.subject = emailSubject;
message.setHtmlBody(emailFinalBody);
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
And, this is the mail that the customer gets:
As you can see from the code, i have added setSenderDisplayName(senderDisplay)
string while sending the mail, but in the received mail, sender is <mail id of the org logged in user> via <a url>
, and I have to go to the details of the mail to see the senderDisplay
. Also, the subject emailSubject
Educational content from SampleAddress, is prefixed with <some code> Sandbox:
, on the mail. So, is there any way to remove all these things? Is there any way to send the mail as it contains only the things that I specified while sending it?
senderDisplayName
?