+ Start a Discussion
Bernd NawrathBernd Nawrath 

Email trigger for Visualforce-Component

Hello dear community, I have a PDF as a visualforce-component and I want this to be sent automatically as an attachment by a trigger when a new account is added. Any advices ?

Thanks in advance ! :)

Create your Email template as a Visualforce template, only rendering the relevant content for your attachment, for example:

<messaging:emailTemplate subject="Invoice - {!relatedTo.Name}" recipientType="Contact" relatedToType="Invoice__c">
    <messaging:attachment renderAs="pdf" filename="{!relatedTo.Name} rendered="{!relatedTo.Template__c == 'Email Template 1'}">  
    <messaging:htmlEmailBody >
        Dear Customer,

        Here is your Invoice.  Please pay now, or else!

1. create a picklist on account and update that field from trigger 
2. create a workflow and add the email alert as action by selecting the email template 
activate the same and update the picklist values relavant to the action...

This is just a high level idea which I didn't tested... But this approach should work.