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
Saravanan @CreationSaravanan @Creation 

Sending user Email

Hi All,

I am creating standard user with following values .

User:{Generate_new_password__c=true, Phone=34543432, TimeZoneSidKey=Europe/London, UserPermissionsSFContentUser=true, LanguageLocaleKey=en_US, UserPreferencesContentEmailAsAndWhen=true, ProfileId=00eb0000000ct9oAAA, LocaleSidKey=en_GB, LastName=Saravanan, UserPreferencesContentNoEmail=true, EmailEncodingKey=ISO-8859-1, Email=ssaravananbtech@gmail.com, Alias=TeS, Username=ssaravananbtech@gmail.com, FirstName=Selvaraj, MobilePhone=898888665}

For insert i am using below code

                        Database.DMLOptions dmlo = new Database.DMLOptions();
                        dmlo.EmailHeader.triggerUserEmail = true;
                        Database.SaveResult results = database.insert(CreateUser,dmlo);

This code is sending the email to set the password for new user in one org(Sandbox) but not in other org(production). I have checked the below settings in both the org.

1.CRM Content is- Enabled (Because i am using some content related fields)
2. Email deliverability- All email
3. Checked the Test deliverability - receiving email from all IP address.

Is there any thing I need to check apart from these setting.

Thanks in advance!!
GSBassoGSBasso
Hi,

Is the new user being successfully created in your production instance?

If so, what happens if you manually reset their password from within the UI? Is the notification received?

If the user is not being successfully created then you'll need to interrogate the returned SaveResult. One thought I had is that if you are attempting to create exactly the same user then this will fail for sure as the username must be unique across all Salesforce instances.
Saravanan @CreationSaravanan @Creation
Hi thanks for your reply.

The user has been successfully created in production. If I manually reset their password the user is notified.


GSBassoGSBasso
Have you tried checking the email logs? They are a bit difficult to follow but based on the time you created the user and the email address you should be able to confirm whether Salesforce in fact sent out an email.
Saravanan @CreationSaravanan @Creation
Yes I have checked the log file too. Actually its says delivered. But  user didn't receive any mail .
I have checked in Spam too.