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
earlino727earlino727 

first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email

HI  Here is my scenario that causes this error:

I have create a VF page which is a registration form. It is hosted on a Force.com site. What I want to do is this:
When a user enteres contact information, he will get an email notification containing a generic email address called "noreply@someemail.org" listed as the From: Email Header or Sender. I use Org wide Email Addressesmethod setOrgWideEmailAddressId to create this.

However that email doesn't appear and I get an error rmessage that says :

SendEmail failed 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.

Q) Does anyone know if I am receiving this error because the external  user to the Force.com Site is of a profile type that is a Guest  Site User and not  one that is a Salesforce Licensed User like System Admin?

I ask this question because when I run a test locally for this VF Page  within Salesforce (as a System Admin), the test user I use will get the email notification that does contain the Sender Header "noreply@someemail.org"  and no error exception is displayed.

 Thanks in advance!
Best Answer chosen by earlino727
earlino727earlino727
HI qraish,  I thinkI found the answer:

First, I had to go to the user page for Homeschool Site Guesr User  user record and then I edited the Email Address attribute by changing the previous value  (which was an employee email address) to 'noreply@someaddress.com' . I then reran a test on the Sandbox Force.com Site page form and submitted the user information on that page form.   The controller for the site then sends the user an email notification and I verified that the Sender or From email header  was set to  'noreply@someaddress.com' .  So I never really had to use Org Wide Email Address at all in my APEX code. I just had to make sure that the Site Guest User  user record Email attribute  was set to 'noreply@someaddress.com' .

Next, within the code I had the controller code setup the email using Subject, SenderDIsplayName,Replyto, and the BCC headers before sending the email.

I am still using Portal users but this should be the last project in using Protals for us.

All Answers

qraishqraish

If you haven't done so already, may be you can check if that Org Wide Email Address has the profile of the sites user listed when 'Allow Only Selected Profiles to Use the From Address' is selected

earlino727earlino727
Thanks qraish I will have to check but I am thinking it does not since this user is not a Salesforce platform licensed user but some guest license. So it nay not be in the list .
earlino727earlino727
I am not sure Salesforce allows for loading a custom User with User License into the Org Wide Email Address list. When a Salesforce licensed User's profile is created then that profile automatically gets loaded into the Org Wide Email Address (OWEA)  list of profiles I think. However this  Guest User  with User License does not authomatically load to OWEA. I am using a portal.
earlino727earlino727
HI qraish,  I thinkI found the answer:

First, I had to go to the user page for Homeschool Site Guesr User  user record and then I edited the Email Address attribute by changing the previous value  (which was an employee email address) to 'noreply@someaddress.com' . I then reran a test on the Sandbox Force.com Site page form and submitted the user information on that page form.   The controller for the site then sends the user an email notification and I verified that the Sender or From email header  was set to  'noreply@someaddress.com' .  So I never really had to use Org Wide Email Address at all in my APEX code. I just had to make sure that the Site Guest User  user record Email attribute  was set to 'noreply@someaddress.com' .

Next, within the code I had the controller code setup the email using Subject, SenderDIsplayName,Replyto, and the BCC headers before sending the email.

I am still using Portal users but this should be the last project in using Protals for us.
This was selected as the best answer