PDFファイルを作成して、Salesforceメールテンプレートに添付
Visualforceメールテンプレ―ド:
<messaging:emailTemplate subject="test: {!relatedTo.name}" recipientType="Contact" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
添付送付させていただきます。
ご確認お願いいたします。
</messaging:plainTextEmailBody>
<messaging:htmlEmailBody >
<html>
<body>
<p>添付送付させていただきます。</p>
<p>ご確認お願いいたします。</p>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:attachment renderAs="PDF" filename="Invoice.pdf">
<c:OppAttachmentComponent opportunityId="{!relatedTo.Id}" opportunity="{!relatedTo}"/>
</messaging:attachment>
</messaging:emailTemplate>
Component : OppAttachmentComponen
<apex:component controller="OppAttachmentComponentController" access="global" >
<apex:attribute name="opportunityId" description="OpportunityId" assignTo="{!OpportunityId}" type="Id" />
test
{!opportunity.Name}
</apex:component>
commponent controller : OppAttachmentComponentController
global class OppAttachmentComponentController {
global String OpportunityId{
get;
set {
UpdateContents2(value);
}
}
public void UpdateContents2(String OpportunityId) {
if (OpportunityId != null) {
List<Opportunity> oppList = [SELECT Id FROM Opportunity WHERE Id =:OpportunityId];
}
}
}