Find your content:

Search form

You are here

Send mail to people other than contact or lead

 
Share

I have a requirement in which I have to write code to send mail to people who are neither contact nor lead. They are people working in our company and do not have any Salesforce login. I have created a workaround by creating contacts of them. And it is always a dangerous thing to have them in Contact as Admin can delete them by mistake. If not now sometimes in future. So my concern is to have a solution in which I can send mail to them without any fear of loosing there contact as it is a continuous basis process. This mail does not go to our client and wholly and solely for internal purpose. Can somebody help me.


Attribution to: Rohit

Possible Suggestion/Solution #1

Salesforce provides functionality to send email to any person regardless of Contact or Lead or User. However it is bound with a quite restrictive Salesforce governor limit:

to a maximum of 1,000 external email addresses per day

Here is a sample code to send email to any email address:

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

    String subject = 'Subject Line ';
    email.setSubject(subject);

    // text
    String body = 'Information you need to send'; 

    // Set HTML body for nice foramtting
    email.setHTMLBody(body);

    // Set eamil address of person who you want to send the email. Also you can set multiple email addresses too.
    email.setToAddresses(new String[]{'name.surname@company.com'});

    Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});

Attribution to: Ashwani
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34964

My Block Status

My Block Content