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

Send email after form is complete.

I need to have an email sent to myself when a new order is placed. It needs to be triggered when the final save button is hit(its in a wizard). I need the "save" button to first save,then trigger the email and perform "step4" action which brings it to an alternate confirmation page. How do I create this trigger?

Heres VF page code:

<apex:page sidebar="false" standardController="lead"   showHeader="false" extensions="GLeadExtension"> 
<apex:composition template="{!$Site.Template}">
<apex:define name="body">
<h1>Conveyor Application Request Part 3/3</h1>
<apex:form >
<apex:pageBlock >

<apex:pageBlockButtons >
<apex:commandButton action="{!step4}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>

<apex:pageBlockSection title="Installation - Additional Information" columns="2">
<apex:inputField value="{!Lead.Capacity_ton_h__c}"/>
<apex:inputField value="{!Lead.Other_intervals__c}"/>
<apex:inputField value="{!Lead.Total_conveying_distance_m__c}"/>
<apex:inputField value="{!Lead.Horizontal_m__c}"/>
<apex:inputField value="{!Lead.Vertical_m__c}"/>
<apex:inputField value="{!Lead.Number_of_bends__c}"/>
<apex:inputField value="{!Lead.Type_of_pipe_system__c}"/>
<apex:inputField value="{!Lead.Diameter__c}"/>
<apex:inputField value="{!Lead.Humidity_of_the_product__c}"/>
<apex:inputField value="{!Lead.Hygroscopic_moisture__c}"/>
<apex:inputField value="{!Lead.Product_picked_up_from__c}"/>
<apex:inputField value="{!Lead.If_Others__c}"/>
<apex:inputField value="{!Lead.The_installation_is__c}"/>
<apex:inputField value="{!Lead.The_operation_is__c}"/>
<apex:inputField value="{!Lead.Other_information__c}"/>

Message Edited by Margiro on 04-24-2009 07:46 AM
Message Edited by Margiro on 04-24-2009 07:48 AM

You need to use add the email functionality to the GLeadExtension action method , step4().

There is sample code for sending Outbound email with apex here.



I'm trying this but I believe that my code for the email is in the incorrect spot because it shows up at the bottom of the page im working on. Where should the code go?
<apex:page sidebar="false" standardController="lead"   showHeader="false" extensions="GLeadExtension"> 

<apex:composition template="{!$Site.Template}">

<apex:define name="body">

<apex:form >

<h1> Conveyor Form Complete </h1>

<b1> Thank You {!Lead.firstname}. You will be contacted shortly about your order.</b1>




Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

String[] toAddresses = new String[] {''};


mail.setSenderDisplayName('Conveyor Order');

mail.setSubject('New Conveyor Order Created : ' + Lead.Id);

mail.setPlainTextBody('A new conveyor order: ' + lead.Id +' has been entered');

mail.setHtmlBody('Your case:<b> ' + case.Id +' </b> has been created'+

' View case <a> href='+lead.Id+'>click here</a>');

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });