+ Start a Discussion
Sumit  61Sumit 61 

How to Set From Email Address In Apex Email Service

        for(alu_Opportunity_Matching__c opp :OppMapByIDs.values()){           
            if(opp.Applicant_Student_Record__c != null){
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
                singleMail.setTargetObjectId(opp.Applicant_Student_Record__c);
                singleMail.setTemplateId(et.Id);
                singleMail.setWhatId(opp.Id);
                singleMail.setSaveAsActivity(false);
                singleMail.setReplyTo('mycareer@gmail.com');
                   singleMail.setSenderDisplayName('Career Development');
                singleMail.setFileAttachments(fileAttachments);
                emails.add(singleMail); 
            }
        }  
        Messaging.sendEmail(emails);
v varaprasadv varaprasad
Hi Sumit,

Please check once below code : 
OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'doNotReply@blahblah.com'];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if ( owea.size() > 0 ) {
    mail.setOrgWideEmailAddressId(owea.get(0).Id);
}

More info :  https://salesforce.stackexchange.com/questions/1243/setting-a-from-address-in-singleemailmessage

Hope this helps,
Please let me know incase of any further assistance.


Thanks
Varaprasad