Skip to main content
Code is here :

global without sharing class PostInstallClass implements InstallHandler {

    global void onInstall(InstallContext context) {    

               

        User u = [Select Id, Email,name from User where Id =:context.installerID()];   

        List<String> toAddresses = new list<String>();

        toAddresses.add(u.Email);        

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        mail.setToAddresses(toAddresses);

        mail.setReplyTo('vishnukumarramawat@gmail.com');

        mail.setSenderDisplayName('My Package Support');

        mail.setSubject('Package install successful');

        mail.setPlainTextBody('Thanks for installing the package.');

        Messaging.sendEmail(new Messaging.Email[] { mail });

        

        //Send mail to developer whenever new user install it

        toAddresses = new list<String>();

        toAddresses.add('vishnukumarramawat@gmail.com');        

        mail = new Messaging.SingleEmailMessage();

        mail.setToAddresses(toAddresses);

        mail.setReplyTo(u.Email);

        mail.setSenderDisplayName('Twins Package installed');

        mail.setSubject('New user install successful');

        mail.setPlainTextBody('Username : '+u.name + '\n' +'Email : ' + u.email);

        Messaging.sendEmail(new Messaging.Email[] { mail });

    }   

}
3 answers
  1. Mar 25, 2015, 8:42 AM
    Hi Vishnu,

    when incorporating a post install script using the InstallHandler interface, remember to specify its class name in the Post Install Script field in the Package Detail before you upload the package.

    Hi Vishnu,when incorporating a post install script using the InstallHandler interface, remember to specify its class name in the Post Install Script field in the Package Detail before you upload the p

    Hope this helps.
0/9000