You need to sign in to do that
Don't have an account?
Ty Whitfield
Set the emailmessage fromaddress via API
I have successfully been able to add an emailMessage to SF via the API. I will need to do one of the two options:
- Not have SF send the email to the recipient once added. This is because we have already sent the email and just placing a copy in SF for our records
- Have the ability to change the fromAddress via the API. If we remove the email sent from our website and only have the SF one to be sent, we will need to change the from email address. I have added the email to the Organization-Wide Email addresses and associated it to the correct profile, however, I don't know where to switch it.
SingleEmailMessage emailMessage = new SingleEmailMessage(); if (!string.IsNullOrEmpty(templateid)) { emailMessage.templateId = templateid; } else { emailMessage.subject = subject; emailMessage.htmlBody = Server.UrlDecode(body) ; } emailMessage.toAddresses = new String[] { email }; emailMessage.saveAsActivity = true; emailMessage.targetObjectId = contactId; SingleEmailMessage[] messages = { emailMessage }; SendEmailResult[] results = binding.sendEmail(messages); if (results[0].success) { // Console.WriteLine("The email was sent successfully."); } else { SendEmail("xxxxxx@xxx.com", "Error SingleEmailMessage add", "The email failed to send: " + results[0].errors[0].message); } sflogout();
Can you please provide the complete implementation of the email message code? Is it in any apex class?