2

Here's the setup of my problem, and i'm not sure how to get started.

initial screen -> my user is on a VF page and makes some HTML selections. Also, they select a number of notes and attachments. No DML occurs

final screen --> my user is on the email template page, and an attachment is created based on the selections in the initial screen. Also, each note and attachment they selected is added as an attachment to the email template.

How do I do that? I know components let you make attachments for visualforce email templates. One idea is that i do URL hacking and pass a lot of what i need as paramaeters, and then do my soqls in the controller of my component. However, i can't quite put the pieces together

Any better ideas?

3

Since you're already in Visualforce and Apex land, then your easiest bet would likely be to construct a SingleEmailMessage in Apex and use that instead of the standard email UI. http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm

You can still use Visualforce templates, and you can also add file attachments. Additionally (I havent had to use this for a long time, so my memory might be foggy), you can set the WhatId, and the email should show up in the whatid's detail page under related lists, provided the page layout is set up in that regard.

4
  • Ah, one constraint, the user needs to be able to add more attachments manually... and update the email template Apr 7 '14 at 21:26
  • You can add attachments using blob types and apex:inputFile, although you may have some difficulty with multiple files, rerendering, etc. Also, with the email template update, you're not going to do that unless the user goes in as an admin and updates the template. Either that, or you can write a metadata api based tool for updating the template from apex/visualforce. Apr 7 '14 at 21:31
  • regarding the last bit, a user can modify the <messaging:plainText/> section of visualforce templates. it's a very handy thing. :) Apr 7 '14 at 21:33
  • 1
    Users updating email templates defeats the purpose of an email template. If the user has to edit the email text before sending but should use certain text as a starting point, then you are better off setting the default/initial text somewhere else, such as in your VF controller. So you are correct that the user can edit a messaging:plainText area, but not that the user can save that change back to the template. Apr 7 '14 at 21:58
0

After a considerable amount of work, this is not possible, given the business requirements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.