+ Start a Discussion

Creating User From Apex Code

Hi All,

How can we make salesforce to send the user creation email to user when we create a user from apex code.

I could send the Reset Password mail using System.ReSetPassword method.

But when we used it Email says that

your password has been reset.




I am not sure whether this is what you are looking for. But I think you can create an email template similar to the User creation mail and then send the email via Apex code after verifying successful User creation.







           Are you creating a customer portal user via sites though apex code then you can send an email through workflow by specifying with email via emailo templates using certain criteria but if you are creating an normal user then temporary password email can be sent to user by using the following code snippet:-

           Database.DMLOptions dlo = new Database.DMLOptions();

           dlo.EmailHeader.triggerUserEmail= true;


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.                      


Thanks for you replies


I tries what you said in this way

Database.DMLOptions dlo = new Database.DMLOptions();
            dlo.EmailHeader.triggerUserEmail= true;

but it didnt work