+ Start a Discussion
RupaliJRupaliJ 

"Portal User Creation" email delivery failed if that portal user created using Apex Code

Hi,

I've trigger on Quote which create "Portal User" for its associated contact if not exist.
 
User newPortalUser = new User(Alias = 'AK',
                             EmailEncodingKey = 'UTF-8', 
                             LastName = 'AK', LanguageLocaleKey = 'en_US',
                             LocaleSidKey = 'en_US', 
                             Email = myContact.Email ,
                             ProfileID = myProfile.Id, 
                             ContactId = myContact.Id,
                             TimeZoneSidKey = 'America/Los_Angeles',
                             Username = 'test@dev.com'
                            );    
insert newPortalUser;

Code runs without any error and even Portal User also created in org, but email delivery failed i.e. email address provided while user creation not receives any mail.

Also tried following line of code with above:
 
Database.DMLOptions dmo = new Database.DMLOptions(); 
dmo.EmailHeader.triggerUserEmail = false; 
newPortalUser.setOptions(dmo);

​But still result is same. No email delivered to created Portal User.

I also checked "Deliverability" setting under "Email Administration" and Access level is already set to "All mails". 

Is there any other reason of email is not being sent?

Thanks,
Rupali 
 
Arunkumar RArunkumar R
hi,

Can you try out the below link example,

http://salesforcekings.blogspot.in/2013/11/salesforce-community-user-creation.html

let me know if still you face an issue.
Harpreet On CloudHarpreet On Cloud
Did not "Email Log Files" help? Did it not provide any error? You can check Email Log Files under "Monitoring" in Setup area