• Adonay Palacios
  • 0 Points
  • Member since 2022

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1


The following links shows how to attach pdf and send email using Apex code


The part in the article given at end of my post reads a pdf and set its content as attachment.But this example only shows how to attach VisualForce page which is renderd as PDF.


When I tried same example code with a PDF file hosted on some other server and is public(Say: http://myserver.com/myFile.pdf). The VisualForce page runs without error, but does not give any response. Doesn't Apex attaching external files as attachment with email. If Not is there any other workaround. The problem is I want to attach a PDF which is hosted on some other server and send email using Apex. 



Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        // Reference the attachment page and pass in the account ID
        PageReference pdf =  Page.attachmentPDF;

        // Take the PDF content
        Blob b = pdf.getContent();

        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();