You need to sign in to do that
Don't have an account?
Chrystele Benjamin
Opportunity's Notes & Attachments into email template
Hello,
Could anyone help me fix the bold portion of this visualforce email template code so that any document attached to the opportunity in the Notes & Attachments section gets included in the email alert as an attachment?
<messaging:emailTemplate recipientType="Contact"
relatedToType="Opportunity"
subject="CSF processing request for: {!relatedTo.name}"
replyTo="xxxx.xxxx@xxx.net" >
<messaging:htmlEmailBody >
<html>
<body>
<STYLE type="text/css">
TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1; text-align: center }
TD {font-size: 11px; font-face: verdana }
TABLE {border: solid #CCCCCC; border-width: 1}
TR {border: solid #CCCCCC; border-width: 1}
</STYLE>
<font face="arial" size="2">
<p>CSF PROCESSING REQUEST</p>
<p>Please find attached the detailed CSF for:<p/>
<p> Opportunity:<b> {!relatedTo.name}</b>
<br/>Account: <i><b> {!relatedTo.Account.name}</b> </i>
<br/>Opp ID:<b> {!relatedTo.Opp_ID__c} </b>
<br/>Opportunity Owner: <b>{!relatedTo.owner.name}</b>
<br/>Operating Region: <b> {!relatedTo.xxxxxx_Operating_Region2__c}</b>
<p/>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:emailTemplate subject="Opps Signed Documents" recipientType="Contact" relatedToType="Opportunity">
<messaging:htmlEmailBody >
<p>Attachments</p>
<apex:repeat value="{!relatedTo.Attachments}" var="a">
<p><a href="{!URLFOR($Action.Attachment.Download, a)}">{!a.Name}</a> ({!a.BodyLength} B)</p>
</apex:repeat>
</messaging:htmlEmailBody>
Could anyone help me fix the bold portion of this visualforce email template code so that any document attached to the opportunity in the Notes & Attachments section gets included in the email alert as an attachment?
<messaging:emailTemplate recipientType="Contact"
relatedToType="Opportunity"
subject="CSF processing request for: {!relatedTo.name}"
replyTo="xxxx.xxxx@xxx.net" >
<messaging:htmlEmailBody >
<html>
<body>
<STYLE type="text/css">
TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1; text-align: center }
TD {font-size: 11px; font-face: verdana }
TABLE {border: solid #CCCCCC; border-width: 1}
TR {border: solid #CCCCCC; border-width: 1}
</STYLE>
<font face="arial" size="2">
<p>CSF PROCESSING REQUEST</p>
<p>Please find attached the detailed CSF for:<p/>
<p> Opportunity:<b> {!relatedTo.name}</b>
<br/>Account: <i><b> {!relatedTo.Account.name}</b> </i>
<br/>Opp ID:<b> {!relatedTo.Opp_ID__c} </b>
<br/>Opportunity Owner: <b>{!relatedTo.owner.name}</b>
<br/>Operating Region: <b> {!relatedTo.xxxxxx_Operating_Region2__c}</b>
<p/>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:emailTemplate subject="Opps Signed Documents" recipientType="Contact" relatedToType="Opportunity">
<messaging:htmlEmailBody >
<p>Attachments</p>
<apex:repeat value="{!relatedTo.Attachments}" var="a">
<p><a href="{!URLFOR($Action.Attachment.Download, a)}">{!a.Name}</a> ({!a.BodyLength} B)</p>
</apex:repeat>
</messaging:htmlEmailBody>
Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102
All Answers
You need to use the <messaging:attachment> tag to add the attachments in email template. Sample code is given below:
You can get more help on this link:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_attachments.htm
Let me know if you face any more issues.
Thanks,
Abhishek Bansal.
I've seen that example before but I don't know how to make it work to pull out of the opportunity object. I get error messages. I tried replacing "cases" with "Opportunity" and the next 4 lines with opp fields but I'm very elementary still with coding so what do I use instead of "cx"? Any chance you can update my portion of the code? Pretty please?? :-)
You can use the code that you are using but instead of <messaging:emailTemplate> tag you should use <messaging:attachment>
Here is the full code with your example in bold:
<messaging:emailTemplate recipientType="Contact"
relatedToType="Opportunity"
subject="CSF processing request for: {!relatedTo.name}"
replyTo="xxx.xxx@xxx.net" >
<messaging:htmlEmailBody >
<html>
<body>
<STYLE type="text/css">
TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1; text-align: center }
TD {font-size: 11px; font-face: verdana }
TABLE {border: solid #CCCCCC; border-width: 1}
TR {border: solid #CCCCCC; border-width: 1}
</STYLE>
<font face="arial" size="2">
<p>CSF PROCESSING REQUEST</p>
<p>Please find attached the detailed CSF for:<p/>
<p> Opportunity:<b> {!relatedTo.name}</b>
<br/>Account: <i><b> {!relatedTo.Account.name}</b> </i>
<br/>Opp ID:<b> {!relatedTo.Opp_ID__c} </b>
<br/>Opportunity Owner: <b>{!relatedTo.owner.name}</b>
<br/>Operating Region: <b> {!relatedTo.xxxxx_Operating_Region2__c}</b>
<p/>
<p />
</font>
</body>
</html>
<messaging:attachment>
<apex:repeat var="cx" value="{!relatedTo.Attachments}">
Opportunity: {!cx.Name}
Account: {!cx.AccountID}
Creator Email: {!cx.Contact.email}
Opp ID: {!cx.Opp_ID__c}
</apex:repeat>
</messaging:attachment>
Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102
I will highly recommend you every chance I get.
Thank you,
CB