You need to sign in to do that
Don't have an account?
Steve Berley
setOrgWideEmailAddressId() giving Invalid ID error
I’m having a problem with setOrgWideEmailAddressId() when sending a single email — anyone else running into troubles?
Even though the OWE email address is verified and I’m using the id retrieved from querying the owe object — it ALWAYS gives an “Invalid Id” error.
What am I doing wrong?
Even though the OWE email address is verified and I’m using the id retrieved from querying the owe object — it ALWAYS gives an “Invalid Id” error.
What am I doing wrong?
Check if"Allow All Profiles to Use this From Address" in Organization-Wide Email Addresses is selected on profile.
Can you check API version of controller if you have any?
https://help.salesforce.com/articleView?id=emailadmin_orgwide_addresses_considerations.htm&type=5
Set up a dedicated email address by navigating to Setup -> Administration Setup -> Email Administration -> Organization-Wide Addresses menu. Once you have created an org-wide address (note that Salesforce will require you to confirm the address prior to using it, so if you're going to be sending things from a junk address it would be wise to set up a catch-all mailbox so you receive the confirmation email), grab the Id from the URL and use the setOrgWideEmailAddressId(Id) method on your instance of Messaging.SingleEmailMessage.
If you want to avoid hard-coding an Id, after creating your Org-Wide Address you can query them:
OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'doNotReply@blahblah.com'];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if ( owea.size() > 0 ) {
mail.setOrgWideEmailAddressId(owea.get(0).Id);
}
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Vinay Kumar
https://help.salesforce.com/articleView?id=000340122&type=1&mode=1
Request you to log a case with salesforce support.
Thanks,
Vinay Kumar