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

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 =; = 'Quote_v'+(totalRecords_Attachment+1)+'.pdf';
        myAttach.body = pdf.getContentAsPdf();
        insert myAttach;
        PageReference ref=new PageReference('/_ui/core/email/author/EmailAuthor?p2_lkid=''&rtype=003&p3_lkid=''&doc_id=''&retURL=';
        return ref;

But while returning the valur the URL changes by itself like :
Doc id comes firct by itselt and rtype=003 comes last.

please help on this.