+ Start a Discussion

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;
              body = pdf.getContentAsPDF();
        catch (VisualforceException e) 
              body = Blob.valueOf('Some Text');
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.Body = body;

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    mail.setToAddresses(new String[] { 'test@test.com' });
    mail.setSubject('Article Export Results');
    mail.setHtmlBody('Attached are the Article Export Results');
    // Send the email
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Matthew CokeMatthew Coke
there's discussion on this here. it may not be possible with your email server