How to get congacomposer online pdf into mail attachment saleforce

To attach a Conga Composer-generated PDF to an email in Salesforce, you'll need to follow these steps:

Prerequisites:

  1. Conga Composer is installed and configured in your Salesforce org.
  2. You have a PDF template created in Conga Composer.
  3. You have a Salesforce email template or a custom email template that allows attachments.

Step 1: Generate the PDF using Conga Composer

  1. Go to the Conga Composer dashboard and select the PDF template you want to use.
  2. Configure the template with the necessary data, such as merge fields, using the Conga Composer interface.
  3. Click the "Generate PDF" button to create the PDF document.

Step 2: Save the PDF to a Salesforce attachment

  1. In Salesforce, go to the "Attachments" related list on the object where you want to attach the PDF (e.g., Account, Contact, Opportunity, etc.).
  2. Click the "New" button to create a new attachment.
  3. Select the PDF file generated in Step 1 and upload it to Salesforce.

Step 3: Create a Salesforce email template or use a custom email template

  1. Go to Setup > Email > Email Templates.
  2. Click "New" to create a new email template or edit an existing one.
  3. In the email template, add a placeholder for the attachment using the "Insert Field" button. For example, you can add a placeholder for the PDF attachment using the "Attachment" field.

Step 4: Use Apex code to attach the PDF to the email

  1. Create a new Apex class or edit an existing one.
  2. Use the Messaging.SingleEmailMessage class to create a new email message.
  3. Set the setBody method to use the email template you created in Step 3.
  4. Use the addAttachment method to attach the PDF file generated in Step 1 to the email message.

Here's an example Apex code snippet:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setBody('Your Email Template Name');
mail.setSubject('Your Email Subject');
mail.addAttachment('Your_Attachment_Name', Blob.valueOf(attachment.getBlob()));
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Step 5: Trigger the Apex code

  1. Create a new trigger or edit an existing one.
  2. Set the trigger to fire on the object where you want to attach the PDF (e.g., Account, Contact, Opportunity, etc.).
  3. Use the Apex code snippet from Step 4 as the trigger code.

By following these steps, you should be able to attach a Conga Composer-generated PDF to an email in Salesforce.