function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Email Notification from Org Wide Address

Hi All,


I needed to send an email notification on opportunities with conditions too complex for a workflow rule, so I created a trigger that checks the conditions and sends the email. I was successful on doing this, but now only problem I have is that the notification needs to be sent from a general address (org wide address), and this address should be available only for the trigger, not for the users. But if I do not add the profiles of the users to the org wide address, I get the following error:


caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email


On the other hand, if I give access to the profiles, then the org wide address is available whenever the users want to send any email message.


Does anyone know how to use the org wide address in a trigger without providing access to the user’s profile? Any other solution like running the code always under another user (i.e. system admin)?


Thanks in advance!

Saurabh DhobleSaurabh Dhoble

Not sure what exactly you are trying to do here, but you can send email with the regular SF outbound email service. You can set the "Reply-To" attribute to your custom email address, so that when users reply to the email, it goes to your custom org-wide mailbox.


Sample code is here :- SF Documentation


Let me know if this helps or you are trying to do something else.


Trying to do the exact same thing here. Were you ever able to get this solved? I don't like the "Reply-To" only option.

I don't think that solved the problem Saurabh because I have almost the same issue except for me I get this error exceptiion after users register on our Site Page. After user submits the site registration form an email is "supposed " to be sent out the  is sent out with  the noreply@slomeaddress  email address located in the From Header of the email. I used Org. Wide Email Address too  and it does work from the Visual Force Page but when running it from the site it fails. This may be due to the fact that System Admin is the user for the local Visual Force Page while another User type called Site Guest User is used for SItes. Is there anyway around.
I haven't solved it yet either... :(