+ Start a Discussion
Hong_YanHong_Yan 

Welcome email on user creation

Is there an option that can be sent to send the welcome email to a user when creating the user through apex?

I'm able to create the user successfully, just can't find any option to send the welcome email.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
MoUsmanMoUsman

You can do this using session id and create a url for the user and send back to the user to login https://<endpoint host>/secur/frontdoor.jsp?sid=<session id>"

 

--

Thanks

Usman

All Answers

kiranmutturukiranmutturu

you can do that by implementing a small trigger on user after insert event....

MoUsmanMoUsman

We can achive this using by writting trigger on User sObject to shoot an email, Example is given below.It can be achive using workflow rule but I am not sure with that.

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//Set email address
String[] toAddresses = new String[] {emailAddr};
mail.setToAddresses(toAddresses);
mail.setSubject('Subject - User Creation');
mail.setPlainTextBody('User has been cretaed!');

 --

Thanks 

Usman

MoUsmanMoUsman

You can refer this link as well http://wiki.developerforce.com/page/Code_Sample_-_Testing_Email_Services_with_Inbound_Attachments  to shoot an email.

 

--

Thanks

Usman

Hong_YanHong_Yan

That part makes sense.

 

Now...is there any way to generate the link that automatically lets someone log in as well?

Similar to this one:

 

Log in automatically by clicking https://test.salesforce.com/?c=l14m45AOUMkmWztzlBXtCTy6drmyZGoICDgd8JH3IEAPampMgmZCTMZFkEqiDfjFqEaYuJiB43mPp0t3LWS0n7pFG3Vupn28r59djS_Z4V4w%3D%3D

MoUsmanMoUsman

Hong_Yan,

 

You can use this url link that will allow to direct login to the user I don't know what is our exact requirment but it works  i have used it several time : https://login.salesforce.com/?un=<username>&pw=<yourpassword>

 

--

Thanks 

Usman

Hong_YanHong_Yan

When creating a user through the regular interface, there's a checkbox called 'Generate new password and notify user immediately'. This would send the user an email with that link I had in my previous reply. (the link takes them to a page that requires them to change their password)

 

What I'm trying to do is to replicate that email for users created through apex.

MoUsmanMoUsman

You can do this using session id and create a url for the user and send back to the user to login https://<endpoint host>/secur/frontdoor.jsp?sid=<session id>"

 

--

Thanks

Usman

This was selected as the best answer
Hong_YanHong_Yan

Interesting...I'm definitely going to have to experiment with that and read up on session ids.

I think that will do the trick.

 

Thanks!