I have written apex code to single email trigger seems perfect but i didn't get any email notification please help me out?

I have written apex code to single email trigger seems perfect but i didn't get any email notification to my email do i have to do any settings or any thing wrong in code please help me out ? here is my code

trigger Process on sample__c (before insert, before update) {      for(sample__c sam: Trigger.New){              if(sam.SendCol__c =='Send'){                  if(sam.Send_Email__c !=null){                           Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();                         //create new single email                           String emailAddr = sam.Send_Email__c;                         //getting the email address and seller name                           String[] toAddresses = new String[] {emailAddr};                         mail.setToAddresses(toAddresses);                         //Set whome the email is to be sent                         mail.setReplyTo('[email protected]');                        //Set reply to email address                         mail.setSenderDisplayName('ABCCompany');                        //Set senders name display                          mail.setSubject('Saleforce alert to');                         //Set the email subject                           mail.setPlainTextBody('This is a test email message to');                         mail.setHtmlBody('This is test body message: <b>');                         //set the email body with html style                           Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });                         //send the single email to the seller                   }             }       }  } 

Replay

I think you also need to add below code, to send mail:

mail.setReplyTo('your mail id to whom you send the mail');
mail.setSenderDisplayName('Sender display name');

Hope it helps you :)

Please check Setup -> EmailAdministration -> Deliverability-> Access Level ='All Email'

Category: apex Time: 2016-07-30 Views: 5

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.294 (s). 12 q(s)