• rohit.marathe@tcs.com
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

Hi,

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

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_sending_attachments.htm

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;
        pdf.getParameters().put('id',(String)account.id);
        pdf.setRedirect(true);

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

        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName('attachment.pdf');
        efa.setBody(b);

 

Hi,

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

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_sending_attachments.htm

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;
        pdf.getParameters().put('id',(String)account.id);
        pdf.setRedirect(true);

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

        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName('attachment.pdf');
        efa.setBody(b);

 

I am in the midst of testing the Salesforce Mobile with the Blackberry Simulator B8707g.
I am recieving the below error message.
"Unable to register your Simulator because you are attempting to create a Simulator device and the device address is in use by another user"

How to change the device address? Have anyone of used this simulator?
Any lead to this issue is much appreciated.