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
Adriana Smith 9Adriana Smith 9 

Send email using button on opportunity

I need to send an email to specific users directly from an opportunity.  Ideally, this would be a button named "Request Custom Pricing" that would pop up an email template in another window.  If it could populate the two users that would be great, but at least the template please, with to: fields in it.  Any help doing this would be greatly appreciated, as I'm new to VF or code.....
Best Answer chosen by Adriana Smith 9
Adriana Smith 9Adriana Smith 9
Nevermind, I did with using Javascript!

All Answers

Jasper WallJasper Wall
Hi Adriana,
Create a visualforce page template and link this page to your button. 
Add a button to the detail page of your record and set the Behaviour of this button to invoke a visualforce page. For more details follow the steps given in https://developer.salesforce.com/docs/atlas.en-us.workbook.meta/workbook/button_1.htm

Mark it as the best answer if it helps.

Thanks,
Balayesu
Adriana Smith 9Adriana Smith 9
Unfortunately, I don't know how to create a VF Page Template to link....
Jasper WallJasper Wall
Hi Adriana,

You can create VF email template like this,
 
<messaging:emailTemplate recipientType="Contact"
	relatedToType="Account"
	subject="Case report for Account: {!relatedTo.name}"
	language="{!recipient.language__c}"
	replyTo="support@acme.com">

	<messaging:htmlEmailBody>
		<html>
			<body>

			<p>Dear {!recipient.name},</p>
			<p>Below is a list of cases related to {!relatedTo.name}.</p>
			<table border="0" >
				<tr>
					<th>Case Number</th><th>Origin</th>
					<th>Creator Email</th><th>Status</th>
				</tr>
				<apex:repeat var="cx" value="{!relatedTo.Cases}">
				<tr>
					<td><a href = 
						"https://***yourInstance***.salesforce.com/{!cx.id}">{!cx.CaseNumber}
					</a></td>
					<td>{!cx.Origin}</td>
					<td>{!cx.Contact.email}</td>
					<td>{!cx.Status}</td>
				</tr>
				</apex:repeat> 
			</table>
			<p/>
			<center>
				<apex:outputLink value="http://www.salesforce.com">
					For more detailed information login to Salesforce.com
				</apex:outputLink>
			</center>
			</body>
		</html>
	</messaging:htmlEmailBody>
</messaging:emailTemplate>

For more details, see the below link,

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_creating.htm


Thanks,
Balayesu
Adriana Smith 9Adriana Smith 9
This is triggering an error message of, could you help identify what the issue is?  
Error: Request_for_Pricing line 8, column 2: The markup in the document following the root element must be well-formed
Error: The markup in the document following the root element must be well-formed.


<messaging:emailTemplate subject="Pricing Request Submitted" recipientType="User" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

<body>

<p> Dear {!recipient.name},<p>

<p> {!Opportunity.OwnerFullName} is requesting custom pricing for {!Opportunity.Account}, for his opportunity related to {!Opportunity.Name} .</p>

<p> -Previous Job Number or Publication:<p>
<p> -Quantity:<p>
<p> -Page Count: <p>
<p> -Flat and Finished Size: <p>
<p> -Specific Fold: <p>
<p> -Are there PMS colors? <p>
<p> -Paper Stock/Weight: <p>
<p> -Any Special Features (Die Cut, Gloss, Emboss, etc)? <p>
<p> -Misc. Information: <p>

<p> Thank you! <p>

</body>
</html>
</messaging:htmlemailbody>
</messaging:emailTemplate>
Adriana Smith 9Adriana Smith 9
Hi Balayesu, could you help me with the error message I'm getting, above?
Adriana Smith 9Adriana Smith 9
Nevermind, I did with using Javascript!
This was selected as the best answer