+ Start a Discussion
Khaled YoussefKhaled Youssef 

alert email when anyone install my package in salesforces

how i procced to create a apex class or trigger class to  send automaticly an email alerts to notify me that my  package is downloaded ?
Rajiv Penagonda 12Rajiv Penagonda 12
Khaled, salesforce provides an option to include Post Installation Script as part of your package. This feature however is available only for managed packages. If your's is a managed package you can refer below links to created Post Installation Scripts for it.


Sample code below:
global class MyInstallationHandler implements InstallHandler {
	global void onInstall(InstallContext argContext) {
		Messaging.SingleEmailMessage lEmail = new Messaging.SingleEmailMessage();
		lEmail.setSubject('Someone Installed my Package!! yay!');
		lEmail.setHtmlBody('Congrats, you have a new Client!');
		lEmail.setToAddresses(new List<String> {'test@test.com'});
		Messaging.sendEmail(new List<Messaging.Email> {lEmail}, false);

Hope this helps.
Naval Sharma4Naval Sharma4
Hi Khaled,

This can be achieved using post installation script class in your package. A post install script always gets executed when a package is installed in a org.

For more information you can go through this link - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_install_handler.htm
Khaled YoussefKhaled Youssef
I apologize ur help , but i have another question , when a new client install a package , in which table i have a new record ( account or user ) or in another table ? . i have an idea to create a trigger in the table to send an email when i have a new record ? 
your opinion ? thanks 
Khaled YoussefKhaled Youssef