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
trsmithtrsmith 

Visualforce email template attachment not working when setting template in URL

I have created a Visualforce email template that automatically attaches a PDF rendering of a quote from the opportunity object. It works fine when manually selecting the template from the email author page.

However, if I create a custom button on the opportunity page to take me to the email author page with the whoid, whatid, and template id defined in the URL, the email subject and body show up just fine but there is no attachment. Anyone else run into this? Any ideas on a fix?

Message Edited by trsmith on 11-17-2008 01:08 PM

Message Edited by trsmith on 11-17-2008 01:10 PM
Best Answer chosen by Admin (Salesforce Developers) 
Jeff TalbotJeff Talbot

I had the same problem today.

 

I found a post that suggested adding "&new_template=1" to the URL.

 

No idea why it worked, but it worked. The attachment is no longer missing.

All Answers

blahblahistakenblahblahistaken

Yes,

  Having almost this exact problem...  did you solve it?

JMPlayer22JMPlayer22

I have this exact same problem--I went and looked into seeing if I could maybe copy the javascript behind the templateselector.jsp when you hit the "select template" button on emails and then put it into an s-control button--

 

I was trying to figure out where the difference was between selecting the template that way and selecting it via the URL line...but I couldn't really figure it out...

 

Hopefully somebody will come up with some sort of solution soon

 

Jeff TalbotJeff Talbot

I had the same problem today.

 

I found a post that suggested adding "&new_template=1" to the URL.

 

No idea why it worked, but it worked. The attachment is no longer missing.

This was selected as the best answer
blahblahistakenblahblahistaken
Wow, thanks very much.  Works like a charm!
JMPlayer22JMPlayer22
Worked for me too! Awesome! Thanks for the post...I'm using this so that the salesmen won't have to save an APEX-generated PDF to their desktop before attaching to an email and this cuts out all that mess...now they can just click a button to send a quote via email with the proposal information attached in the PDF.
juacojuaco

Hi:

 

I'm trying to do the exact same thing but I'm using a professional edition.  I'm able to use visualforce but do not have access to APEX code.  Do you know if it is possible to achieve the automatic pdf attachment without using APEX. Or is there a standardController that I can use?

JMPlayer22JMPlayer22

I'm not sure how limited the Professional Edition is as far as what you can and can't use.  I know you said you can't use APEX code, but does that just mean you can't create APEX classes and triggers?  Do you have the ability to create visualforce email templates in Professional Edition? If so, then you should be able to use something like the following and use HTML.  It just depends if you're able to create visualforce email templates.

 

<messaging:emailTemplate subject="Here is your proposal!" recipientType="Contact" relatedToType="Opportunity">
<messaging:htmlEmailBody >

<!--EMAIL BODY (can be HTML)-->

</messaging:htmlEmailBody><!---END EMAIL BODY-->

<messaging:attachment renderAs="pdf" filename="Quote">


<!---------------------------------PDF Body (Can be HTML)--------------------------------------->



</messaging:attachment>
</messaging:emailTemplate>

juacojuaco
Thank you JMPlayer22, that's what I needed. Regards
TedLiuTedLiu

Hi,

 

My opportunity has some files attach to it under "Notes and Attachment" section.

 

Do you know how I can include these files in the email as attachments.

 

Any info will be appreciated.

 

Thanks

JMPlayer22JMPlayer22

I apologize in advance because this is going to be broad...but maybe you could write a class that does a query to pull all the attachments/notes related to the record you're sending the email from and then have your APEX code call that class...and render them into a pdf attachment on the email...? 

 

I know it's not specific...just brainstorming.

mauricio.ramos@corpitalmauricio.ramos@corpital

how would you approach to doing this?? Any examples that you can show?? 

 

Thanks!

SelvaRathinamSelvaRathinam
its working..

window.open("/_ui/core/email/author/EmailAuthor?retURL=/{!Lead.Id}&p2_lkid={!Lead.Id}&rtype=00Q&p26=xxx@gmail.com&template_id=0034543000b4Dx&new_template=1","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, width=800, height=650");