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
Swaggy BSwaggy B 

Allow Upload/Associate file attachment when sending an email.

Is there any type of way to send a email with an attachment and automaically have it attached to the Notes & Attachments section.
AshwaniAshwani
You can do this by Apex code:

Here is the way:

// 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);

This link should help: http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_sending_attachments.htm