Activity Forums Salesforce Questions and Answers How can I send an email while using PageReference getContent() method in Salesforce?

  • How can I send an email while using PageReference getContent() method in Salesforce?

  • Prachi

    Member
    December 8, 2019 at 3:47 am

    How can I send an email while using PageReference getContent() method in salesforce?

  • Yogesh

    Member
    December 9, 2019 at 7:16 am

    Hello,

    PageReference ref = Page.PDF_DEMO;
    Blob b = ref.getContentAsPDF();

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

    Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
    efa1.setFileName('attachment_WORK.pdf');
    efa1.setBody(b);

    String addresses;
    email.setSubject( Subject +String.valueOf(DateTime.now()));
    email.setToAddresses( EmailIds );
    email.setPlainTextBody(Body);
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

Viewing 1 - 2 of 2 posts

Log In to reply.





Popular Salesforce Blogs

Popular Salesforce Videos