You need to sign in to do that
Don't have an account?
using attachment table in visualforce email templates
Hi,
I have created a visualforce email template. The body of this template contains some text and few merge fields linked to custom object. I am able read the data using merge fields successfully.
But this custom object also allows users to attach files. So I need to send those attached files (if any) with the same email.
I have tried different options but none of them worked for me. Now for time being what i did is that i added a custom component in my mail body and that custom component has a apex:repeat control that gives the link and content type of attachments in a tabular format. Below is my custom component:
<table cellpadding="1" cellspacing="0" width="100%" border="1">
<tr><td colspan="2"><b>Attachments</b></td></tr>
<tr><td><b>File Name</b></td> <td><b>Content Type</b></td></tr>
<apex:repeat value="{!attachments}" var="attachment">
<tr>
<td><apex:outputLink value="https://c.cs17.content.force.com/servlet/servlet.FileDownload?file={!attachment.Id}"> {!attachment.name}</apex:outputLink></td>
<td>{!attachment.contentType}</td>
</tr>
</apex:repeat>
</table>
But the above solution requires the user to be connected to the internet and login to salesforce to access the attachments since the files are not physically attached to mail.
Do we have any way through which we can read attachments from attachment table and send as attachments using visualforce email templates. Also there may be 1 or more than one attachment.
Thanks,
Vicky
Hi, Thanks for your response.. I know we can use messaging:attachment tag but I am reading the attachments dynamically from Attachment table so I dont know what would be the content type and other details.
There could be one or more than one attachment so cant predict how many messaging:attachment tag to add.
Also my VisualForce Email template is dependent on some other custom object. So I cannot put 'Attachment' in 'Related to' attribute of email template.