You need to sign in to do that
Don't have an account?

how to set Organization wide email addressId for visualforce email templates
hi
can u please tell me how to set
setOrgWideEmailAddressId for visualforce email templates.
If i give like this it shows an error that Save error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setOrgWideEmailAddressId(String)
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setOrgWideEmailAddressId('0D2T000000000MH'); //For QA
email.setTemplateId(objEmailTemplate.Id);
email.setTargetObjectId(objContact.id);
email.setSaveAsActivity(true);email.setWhatId(AppointmentId);
email.setSenderDisplayName('Scheduling');
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
can u please help me.
OrgWideEmailAddress owa = [select id, Address,IsAllowAllProfiles from OrgWideEmailAddress where Address = 'noreply@smeaddr.com'];
Then use the ID attribute for this OrgWideEmailObject
email.setOrgWideEmailAddressId(owa.Id); //For QA
My guess is that it may not like the address literal string you used within the method parameter list because i use the same setup and have no problems.
However you may get an exception error because you are trying to use both a seSenderDisplayName method - which uses the email Template name - and setOrgWideEMailAddress method. Use either one or the other. Here is the error messgae I got when using both:
SendEmail failed. First exception on row 0; first error: DUPLICATE_SENDER_DISPLAY_NAME, When an Org-Wide Email Address ID is specified, a sender display name may not be specified.: