function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tom Hoban.ax728Tom Hoban.ax728 

EmailAuthor.jsp - Trouble with attachment via a component with Visual Force Template

I have a visual force email template that uses a component to place an attachment into an email.  I also have code in my application that transitions to the the EmailAuthor.jsp page using a url that looks like this:

 

https://na7.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=a0bA0000000A6slIAC&template_id=00XA0000000OHXmMAO

 

As you can see, I am providing a whatId and a template id.

 

When I arrive at the EmailAuthor page, at first glance everything looks good.  I see text from my template in the body and I see data from my relatedTo record properly merged into the email.  Unfortunately though, the attachment does not appear.  If I then click on the button to "select a template" and then choose the template that was provided in the above url, the page refreshes and the attachement is now shown on the page.  Of course, the whole reason why I provided the template id in the url was so the user doesn't have to select it.

 

Has anyone encountered this problem before and found a way to resolve it?

 

My template looks like:

 

<messaging:emailTemplate subject="Past Due Balancexx" recipientType="Contact" relatedToType="DunningNoticeQueue__c">
  <messaging:htmlEmailBody >
     <br><apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
     <br><br><br>Dear {!recipient.firstName}:

     <br><br>This is to inform you that you owe: {!relatedTo.AR_Summary_Unworked__r.Total_AR_Balance__c}
     <br><!apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
  </messaging:htmlEmailBody>
  <messaging:attachment renderAs="application/vnd.ms-excel" filename="invoices" >  
     <c:DunningInvoiceAttachment dunningQueueId="{!relatedTo.Id}"/>  
  </messaging:attachment>
</messaging:emailTemplate>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Venkat PolisettVenkat Polisett


Tom,

 

Add the following to your emailauthor.jsp url and see if it works.

 

&new_template=1

 

 

Thanks,

Venkat Polisett

 

Tom Hoban wrote:

I have a visual force email template that uses a component to place an attachment into an email.  I also have code in my application that transitions to the the EmailAuthor.jsp page using a url that looks like this:

 

https://na7.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=a0bA0000000A6slIAC&template_id=00XA0000000OHXmMAO

 

As you can see, I am providing a whatId and a template id.

 

When I arrive at the EmailAuthor page, at first glance everything looks good.  I see text from my template in the body and I see data from my relatedTo record properly merged into the email.  Unfortunately though, the attachment does not appear.  If I then click on the button to "select a template" and then choose the template that was provided in the above url, the page refreshes and the attachement is now shown on the page.  Of course, the whole reason why I provided the template id in the url was so the user doesn't have to select it.

 

Has anyone encountered this problem before and found a way to resolve it?

 

My template looks like:

 

<messaging:emailTemplate subject="Past Due Balancexx" recipientType="Contact" relatedToType="DunningNoticeQueue__c">
  <messaging:htmlEmailBody >
     <br><apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
     <br><br><br>Dear {!recipient.firstName}:

     <br><br>This is to inform you that you owe: {!relatedTo.AR_Summary_Unworked__r.Total_AR_Balance__c}
     <br><!apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
  </messaging:htmlEmailBody>
  <messaging:attachment renderAs="application/vnd.ms-excel" filename="invoices" >  
     <c:DunningInvoiceAttachment dunningQueueId="{!relatedTo.Id}"/>  
  </messaging:attachment>
</messaging:emailTemplate>

 

 


 

All Answers

Venkat PolisettVenkat Polisett


Tom,

 

Add the following to your emailauthor.jsp url and see if it works.

 

&new_template=1

 

 

Thanks,

Venkat Polisett

 

Tom Hoban wrote:

I have a visual force email template that uses a component to place an attachment into an email.  I also have code in my application that transitions to the the EmailAuthor.jsp page using a url that looks like this:

 

https://na7.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=a0bA0000000A6slIAC&template_id=00XA0000000OHXmMAO

 

As you can see, I am providing a whatId and a template id.

 

When I arrive at the EmailAuthor page, at first glance everything looks good.  I see text from my template in the body and I see data from my relatedTo record properly merged into the email.  Unfortunately though, the attachment does not appear.  If I then click on the button to "select a template" and then choose the template that was provided in the above url, the page refreshes and the attachement is now shown on the page.  Of course, the whole reason why I provided the template id in the url was so the user doesn't have to select it.

 

Has anyone encountered this problem before and found a way to resolve it?

 

My template looks like:

 

<messaging:emailTemplate subject="Past Due Balancexx" recipientType="Contact" relatedToType="DunningNoticeQueue__c">
  <messaging:htmlEmailBody >
     <br><apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
     <br><br><br>Dear {!recipient.firstName}:

     <br><br>This is to inform you that you owe: {!relatedTo.AR_Summary_Unworked__r.Total_AR_Balance__c}
     <br><!apex:image value="{!relatedTo.Image_1_Web_Address__c}" />
  </messaging:htmlEmailBody>
  <messaging:attachment renderAs="application/vnd.ms-excel" filename="invoices" >  
     <c:DunningInvoiceAttachment dunningQueueId="{!relatedTo.Id}"/>  
  </messaging:attachment>
</messaging:emailTemplate>

 

 


 

This was selected as the best answer
Tom Hoban.ax728Tom Hoban.ax728

Thanks.  This works.