function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public class EmailAttachment{ public static void sendEmail(){ list<Account> lstAccount = [Select Id ,Name from Account]; List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); list<Messaging.EmailFileAttachment> emailAttachmentList = new list<Messaging.EmailFileAttachment>(); for(Account Acc : lstAccount){ Messaging.SingleEmailMessage emailMsg = new Messaging.SingleEmailMessage(); emailMsg.setToAddresses(new list<String>{'CharuDutt8@gmail.Com'}); emailMsg.setSubject('subject'); emailMsg.setHtmlBody('body'); list<Attachment> Att = [Select Id,Name,Body From Attachment where ParentId = :Acc.id]; for(Attachment a: Att){ Messaging.EmailFileAttachment meetingInviteIcs = new Messaging.EmailFileAttachment(); meetingInviteIcs.setFileName(a.Name+'.ics'); meetingInviteIcs.setBody(a.Body); emailAttachmentList.add(meetingInviteIcs); } if(emailAttachmentList.size()>0){ emailMsg.setFileAttachments(emailAttachmentList); } emails.add(emailMsg); } try{ if(emails.size()>0){ Messaging.sendEmail(emails); } }catch(System.EmailException ex){ system.debug('Issue in sending email >> ' + ex.getMessage()); } } }
Hello @CharuDutt
appreciate you
I've tried with above class, but i cound't get the attachment file while receiving the mail.There is nothing wrong with your class
I think there is something problem with notesAndAttachments while sending to an email. i may need to make some changes in query.Thank you.
Thank You!
Hello @CharuDutt
appreciate you
I've tried with above class, but i cound't get the attachment file while receiving the mail.
There is nothing wrong with your class
I think there is something problem with notesAndAttachments while sending to an email. i may need to make some changes in query.
Thank you.
Please Close Your Query By Marking It As Best Answer So It Also Help others In Future
Thank You!