You need to sign in to do that
Don't have an account?
JO_Dev
Send zip file as attachment to email
I need to know how to how to attach a zip file to an email
for (KnowledgeArticleVersion k : kavListFiltered)
{
string trimId = '' + k.KnowledgeArticleId;
trimid = trimid.substring(0,15);
PageReference pdf = new PageReference('/knowledge/articlePrintableView.apexp?id='+trimid);
Blob body;
try
{
body = pdf.getContentAsPDF();
}
catch (VisualforceException e)
{
body = Blob.valueOf('Some Text');
}
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setContentType('application/pdf');
attach.setFileName(k.Title+'.pdf');
attach.setInline(false);
attach.Body = body;
fileAttachments.add(attach);
}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { 'test@test.com' });
mail.setSubject('Article Export Results');
mail.setHtmlBody('Attached are the Article Export Results');
mail.setFileAttachments(fileAttachments);
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
for (KnowledgeArticleVersion k : kavListFiltered)
{
string trimId = '' + k.KnowledgeArticleId;
trimid = trimid.substring(0,15);
PageReference pdf = new PageReference('/knowledge/articlePrintableView.apexp?id='+trimid);
Blob body;
try
{
body = pdf.getContentAsPDF();
}
catch (VisualforceException e)
{
body = Blob.valueOf('Some Text');
}
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setContentType('application/pdf');
attach.setFileName(k.Title+'.pdf');
attach.setInline(false);
attach.Body = body;
fileAttachments.add(attach);
}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { 'test@test.com' });
mail.setSubject('Article Export Results');
mail.setHtmlBody('Attached are the Article Export Results');
mail.setFileAttachments(fileAttachments);
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
https://success.salesforce.com/apex/answers?id=90630000000CuHbAAK