• IvanM
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I have a customer portal which is self-registration enabled. Self-registration happens through Sites. I have setup SiteLogin and SiteRegistration apex classes with some minor changes. The user (and contact) gets created, but the "new user" email is never sent out, even though I am setting the triggerUserEmail option. Here's the code snippet:

 

//Async method, using @future, to create the User record and associate it to the previously created Contact
//This uses @future because you can not have mixed DML operations for standard objects (Account, Contact) and Setup objects(User)
@future static void createUser(String contactId, String userName, String firstName, String lastName, String email, String phone, String zip, String age, String nickName, String profileId) {
       
        System.debug('nickname = ' + nickName + ' phone = ' + phone + ' zip = ' + zip + ' age = ' + age + ' contactid = ' + contactId + ' email = ' + email + ' firstName = ' + firstName + ' lastName = ' + lastName + ' userName = ' + userName + ' profileId = ' + profileId);
       
        Database.DMLOptions dmo = new Database.DMLOptions();
        dmo.EmailHeader.triggerUserEmail = true;
       
        User u1 = new User(contactId=contactId, username=userName, firstname=firstName,
            lastname=lastName, email=email, phone=phone, postalcode=zip, zip__c=zip, age_group__c=age,
            alias = nickName, profileid = profileId, emailencodingkey='UTF-8',
            languagelocalekey='en_US', localesidkey='en_US', timezonesidkey='America/Los_Angeles',
            isportalselfregistered=true
            );
     
        u1.setOptions(dmo);
        insert u1;
    }

 

Again, the user and contact get created just fine, but the email with password is never sent. (The "reset password" email does get sent.) The email template does not use any merge variables.

 

Is there some other setting that I am missing? Is this a Sites issue or a Customer Portal Issue?