Ask Search:
Ankit SharmaAnkit Sharma 

Remove From Address in email.

Hello Everyone. i have create send email code. but wen send email in From address it will be show system admin email. from address are diffrent. how to i handle that in email code.


 EmailTemplate et=[SELECT Id, body,DeveloperName , IsActive FROM EmailTemplate WHERE DeveloperName = 'One_More_Step'];
              List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
              
              Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
              String[] Bccaddresses = new String[] {'meredith@yopmailcom.com'};
              mail.setReplyTo('ankkit101@yopmail.com');
              mail.setHtmlBody(et.body);  
              mail.setSenderDisplayName('Artwork Network1');
              mail.setTemplateID(et.Id);
           
              //mail.setUseSignature(true);
              mail.setSaveAsActivity(true);
              mail.setBccAddresses(Bccaddresses);
              mail.setTargetObjectId(usercurrentcontact.Id);
              mails.add(mail);
              Messaging.sendEmail(mails);

 
Best Answer chosen by Ankit Sharma
Amit SinghAmit Singh
Hi Ankit,

You can add an Email in Organization Wide Default and then use that Email in Email template ID using
setOrgWideEmailAddressId method
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm

All Answers

Amit SinghAmit Singh
Hi Ankit,

You can add an Email in Organization Wide Default and then use that Email in Email template ID using
setOrgWideEmailAddressId method
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm
This was selected as the best answer
Ankit SharmaAnkit Sharma
Hi Amit i add in org. wide email address. but it continue show othere email address in from. in org there i am use many email id also that one show on there correct email id not show.
Amit SinghAmit Singh
Hi Ankit,

What code are you using currently?
Ankit SharmaAnkit Sharma
Thankx amit for your help.. I got solution from your link.. I create soql for org. Wide.
Amit SinghAmit Singh
Awesome. Happy Trailblazing :)