You need to sign in to do that
Don't have an account?
Sundar rajan A
How to send a email with the document in attachment related list as a zip file
Hi Friends,
My requirement is , I need to send a email with the document in the attachment related list, as a zip file. How to add attachment by zippex class,
Many thanks in Advance
My requirement is , I need to send a email with the document in the attachment related list, as a zip file. How to add attachment by zippex class,
Many thanks in Advance
Thank you for your quick responce .I already used the above code It will sending a mail as attached document,I am using the below code It will send seperate zip file attachment for each document.But I need to send a mail as a Single Zip file ,that contains all documents in Attachment related list.
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body from Attachment where ParentId = :oppr.Id])
{
maildatas =a.Body;
zip.addFile('b.txt', maildatas, null);
//finalStrs =a.Body;
zipBlob = zip.getZipArchive();
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
//csvAttc = new Messaging.EmailFileAttachment();
String zipName = 'cases.zip';
csvAttc.setFileName(zipName);
csvAttc.setBody(zipBlob);
fileAttachments.add(csvAttc);
}
//fileAttachments.add(csvAttc);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
//email = new Messaging.SingleEmailMessage();
String[] toAddresses = new List<String> {oppr.email__c};
String subject = 'Report CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('The Merchandise report is attached here.');
// email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
email.setFileAttachments(fileAttachments);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Many thanks in Advance.
I don't have VF Page,I am using Zippex in my apex class.Is there any other solution for send a emil as zip file?
You don't need a VF page, the Zippex library works with or without VF. If you want to add all attachments into the same Zip archive, you need to call the addFile() once per each file.
Here is the code you need to use. Make sure you have installed Zippex: https://github.com/pdalcol/Zippex