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
llisallisa 

Save and email the respective attachemt but it is not getting attached.

Hello Everyone,

I wrote my function currectly .Functionality was to save the pdf and email it with the respective attachment.
Here it saved but not attached in my email page .

public PageReference attachPdfandEmail() 
    {
        PageReference pdf;
        pdf= Page.Quote_PDF;
        pdf.getParameters().put('id', selectedQuote);
        Blob pdfBlob = Test.isRunningTest() ? Blob.valueOf('UNIT.TEST') : pdf.getContent();
        Attachment myAttach = new Attachment();
        myAttach.Parentid = quotes.id;
        myAttach.name = 'Quote_v'+(totalRecords_Attachment+1)+'.pdf';
        myAttach.body = pdf.getContentAsPdf();
        insert myAttach;
        system.debug(myattach.id);
        PageReference ref=new PageReference('/_ui/core/email/author/EmailAuthor?p2_lkid='+acc.id+'&rtype=003&p3_lkid='+quotes.id+'&doc_id='+myattach.id+'&retURL='+quotes.id);
        ref.setRedirect(true);
        return ref;
    }

But while returning the valur the URL changes by itself like :
https://ap2.salesforce.com/_ui/core/email/author/EmailAuthor?doc_id=00P28000006CB6ZEAW&p2_lkid=0012800000EHkmRAAT&p3_lkid=a092800000DdH7ZAAV&retURL=a092800000DdH7ZAAV&rtype=003
Doc id comes firct by itselt and rtype=003 comes last.

please help on this.