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

How to send email from record owner
Hi ,
I need help how to send the email from the record owner name and email adress
code i have used
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setFileAttachments(new Messaging.EmailFileAttachment[] {attachment});
message.setSubject(e.Email_Subject__c);
message.setPlainTextBody(e.Email_Body__c);
message.setSenderDisplayName(users[0].Name);
message.setReplyTo(users[0].Email);
String[] emailRecipients = e.Email_Recipients__c.split(',');
message.setToAddresses(emailRecipients);
mails.add(message);
Here is the issue is owner name is populating but email address is showing off who has scheduled the Batch Apex job
may i know where i am doing the mistake ,let me know if you having any query
thankx
satya
I need help how to send the email from the record owner name and email adress
code i have used
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setFileAttachments(new Messaging.EmailFileAttachment[] {attachment});
message.setSubject(e.Email_Subject__c);
message.setPlainTextBody(e.Email_Body__c);
message.setSenderDisplayName(users[0].Name);
message.setReplyTo(users[0].Email);
String[] emailRecipients = e.Email_Recipients__c.split(',');
message.setToAddresses(emailRecipients);
mails.add(message);
Here is the issue is owner name is populating but email address is showing off who has scheduled the Batch Apex job
may i know where i am doing the mistake ,let me know if you having any query
thankx
satya
Thank you fro your quick responce .
After doing the change as you said it is throwing the below error
Failed to invoke future method 'public static void DoExport()' on class 'ReportExporter' for job id '7072D00000B5U5X'
caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Report_Exporter__c.Owner
Class.ReportExporter.DoExport: line 66, column 1
line no.is ---message.setSenderDisplayName(e.Owner.Name);
Regards,
satya
Here is the query what i am doing in the apex class
Select Id, Name, Report_ID__c, OwnerId, Attachment_Name__c, Email_Subject__c, Email_Body__c, Email_Recipients__c,Weekly_Days__c, Frequency__c, Monthly_Day__c, Last_Run__c from Report_Exporter__c
Now the problem is owner name is displaying but the email address showing who has Scheduled
the batch job.
we have tried with ord-wide-email address their the issue in every mail the display name will be same we need the owner name should displayed thr.
Any thoughts how to implement this reqiurement
Thank you very much
satya
Any thoughts
satya