function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tirantiran 

Problem with PDF

Hello.I have a question about the pdf in Email.I want to attache two pdf,one is generated by salesforce,one is static pdf.It is possible?

 

Now,i can only receive one pdf.Anyone can give a help,thank u !!

 

Code:

 

 PageReference Quittance = Page.QuittanceA;
            Quittance.getParameters().put('id',Opp.id);

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 
                      mail.setBccSender(true);
                      mail.setSenderDisplayName('xxxxx');
                      mail.setCcAddresses(Emails);
                      mail.setSubject(xxx);    
                      mail.setPlainTextBody(
                     xxxxxxxx                  
                       );
                     
            Blob htmBlob = Quittancee.getContent();
            Attachment a = new Attachment(parentId = Opp.id, name=Orec.name + '.pdf' +'    '+'(xxxxxx)', body = htmBlob, isPrivate=false);
            insert a;


      //static pdf          
    List<StaticResource> objPDF = [Select body, name from StaticResource where Name = 'pdf'];
    Messaging.EmailFileAttachment[] objEmailAttachments = new Messaging.EmailFileAttachment[1];
    Messaging.EmailFileAttachment objPDFAttachment = new Messaging.EmailFileAttachment();
    objPDFAttachment.setBody(objPDF[0].Body);
    objPDFAttachment.setFileName(objPDF[0].name + '.pdf');
    objEmailAttachments[0] = objPDFAttachment;
      mail.setFileAttachments(objEmailAttachments);


                  mail.setFileAttachments(new Messaging.EmailFileAttachment[] {myEQuote});
                      mail.setWhatId(Opp.id);
                      mail.setTargetObjectId(OppContact.Id);
                      myEQuote.setFileName(Orec.name.replace('/',' - ')+'.pdf');
                      myEQuote.setBody(htmBlob);
                   
                      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                

 

Devendra@SFDCDevendra@SFDC

Hi Tiran,

 

You can refer following blog from Jeff Douglas.

 

http://blog.jeffdouglas.com/2010/07/16/create-and-email-a-pdf-with-salesforce-com/

 

Hope this helps :)

 

Thanks,

Devendra