You need to sign in to do that
Don't have an account?
m_roark
Creating a VisualForce page overriding the 'EmailMessage' standard controller
I am attempting to create a VisualForce page which looks like the standard 'Send an Email' page. To this page, I want to add an extension which will automatically attach a document when the 'Send' button is clicked.
I can create a page which uses the 'EmailMessage' standard controller, but I cannot determine which component I must use to get the standard 'Send an email' page to load. I have tried using the '<apex:detail>' component to no avail.
Is there a way to do this? And if so, what elements should I be using to do this? Further, is there any documentation prepared, or planned outlining what each of the standard controllers are, and what basic functionality is available for each?
I know that I could probably add a trigger to do what I want, but as I only want this to happen on a specific page I don't want to have to try to code the trigger to prevent the attachment from being attached to every outgoing email.
For those who are wondering, my business case is that I have a VisualForce page which generates an Invoice for our customers. I want to provide a link to our end users on this page, which directs the user to a VisualForce page which looks like the 'Send an email' page. On this new page, they can use the standard email functionality to write an email to a contact at the client site (including adding any templates they would like). When they click 'Send', I want to attach a copy of the Invoice, generated as a pdf.
Any help would be appreciated.
Message Edited by m_roark on 12-02-2008 01:37 PM
I can create a page which uses the 'EmailMessage' standard controller, but I cannot determine which component I must use to get the standard 'Send an email' page to load. I have tried using the '<apex:detail>' component to no avail.
Is there a way to do this? And if so, what elements should I be using to do this? Further, is there any documentation prepared, or planned outlining what each of the standard controllers are, and what basic functionality is available for each?
I know that I could probably add a trigger to do what I want, but as I only want this to happen on a specific page I don't want to have to try to code the trigger to prevent the attachment from being attached to every outgoing email.
For those who are wondering, my business case is that I have a VisualForce page which generates an Invoice for our customers. I want to provide a link to our end users on this page, which directs the user to a VisualForce page which looks like the 'Send an email' page. On this new page, they can use the standard email functionality to write an email to a contact at the client site (including adding any templates they would like). When they click 'Send', I want to attach a copy of the Invoice, generated as a pdf.
Any help would be appreciated.
Message Edited by m_roark on 12-02-2008 01:37 PM
Thanks for the detailed explanation - it helps. Not sure if Chapter 13 in the Developer Guide would help you, but it does have an example of including an attachment with an email message.
I have looked at this functionality, and I could use it to create a page where my users can provide an email address, a subject, and a body, and sends an email to someone. However, I want to provide the rich features of the standard 'Send an email' page, including Contact lookup, the ability to add templates, and the ability to add additional attachments.
As I said in my original post, I have tried using the 'EmailMessage' standard controller for my VisualForce page, in the hopes that this standard controller exposes the appropriate elements, so that I could display an <apex:inputField> which was tied to the 'To:' Contact field, and would render as a Contact lookup. However, I cannot figure out what the name is for the appropriate exposed field to use in the to my inputField. I don't even know if there is one, due to the lack of documentation around standard controllers.
After reading the full of the chapter, what I want to do does not seem possible in the way I want to do it. However, it does seem that I can make a VisualForce template, which will generate the pdf I want as an attachment using the <messaging:attachment> component. This way, my users can select 'Send an email' from the Invoice custom object, and select my VisualForce template which will automatically include the dynamically generated Invoice pdf as an attachment! I will be researching this further, and if this works for my use case, then I will post to note that this is a viable solution.
Message Edited by m_roark on 12-02-2008 02:43 PM
do not include a 'apex: page' component. The 'messaging:attachment' takes the place of this component.
This VisualForce template depends upon a custom object we use for tracking our invoices and invoice line items (so don't expect it to work immediately if you drop it into your environment), but could be easily modified to use a standard object or your own custom object.
Message Edited by m_roark on 12-03-2008 08:25 AM
Thanks m_roak.
My problem was that I was referencing a separate visualforce page (tried to use apex:include). Unfortunately, I'm can't build the page directly into the attachment since the page I'm attaching calls a controllerextension.
I haven't seen a way to declare an extension of the relatedto. object or messaging:emailTemplate. I think my only option is to use the example from Chapter 13 to build a button/apex script that creates the PDF and sends the email.
Were you ever able to come up with a solution for getting the rich functionality (Contact lookup, Template selection, etc)? I'm looking to override the standard Send Email interface for Cases (so our CSEs can update the case and send an email in one screen), but sacrificing the standard Send Email functionlity is not feasible.
uptime_andrew,
No, I did not find this functionality. I ended up using the methods descibed above, and prepopulated the necessary fields on the page load.
while i copied and paste i am getting error this where should i add apex page tag attribute
error :
<apex:page> is required and must be the outermost tag in the markup at line 1 column 1