APEX Single Email

  1. trigger newProInfoTrigger on Merchandise__c (before insert) {
  2.  
  3. for(Merchandise__c mObj : trigger.new) {
  4.  
  5. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  6.  
  7. String[] toAddresses = new String[] {mObj.Supplier_E_Mail__c};
  8. String[] ccAddresses = new String[] {'sfdc.gsk@gmail.com'};
  9.  
  10. mail.setToAddresses(toAddresses);
  11. mail.setCcAddresses(ccAddresses);
  12.  
  13. mail.setReplyTo('emailsravan@gmail.com');
  14.  
  15. mail.setSenderDisplayName('Merchandise - Inventory Management Section');
  16.  
  17. mail.setSubject('Product' + mObj.Name + 'has been received');
  18.  
  19. mail.setBccSender(false);
  20.  
  21. // Optionally append the salesforce.com email signature to the email.
  22. // The email address of the user executing the Apex Code will be used.
  23. mail.setUseSignature(false);
  24.  
  25. // Specify the text content of the email.
  26. mail.setPlainTextBody('New Product in Warehouse: ' + case.Id + ' has been purchased.');
  27.  
  28. mail.setHtmlBody('New Product:<b> ' + case.Id +' </b>is procured.<p>'+'To view your product <a href=https://ap1.salesforce.com/'+case.Id+'>click here.</a>');
  29.  
  30. // Send the email you have created.
  31. Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
  32.  
  33. }
  34. }

Comments

Popular posts