You need to sign in to do that
Don't have an account?
pranavshah
How to send an email when opportunity stage is closed won
Hi All,
Can anyone, please help on the same..
not a code required, can u please share the logic.. so that i can work on same as i am new and learning triggers.
Thanks & Regards
Pranav Shah
Can anyone, please help on the same..
not a code required, can u please share the logic.. so that i can work on same as i am new and learning triggers.
Thanks & Regards
Pranav Shah
Hi Pranav shah
Try this and with your email address
All Answers
- Workflow > Check the condition on Stagename & Select Created and Everytime its edited. Give Email Alert as action
- Apex trigger > Write a trigger on Opportunity and send an email by checking old stagename <> Closed WOn and new stagename == Closed Won
ThanksBrahma
Hi Pranav shah
Try this and with your email address
Why we are using this at Line 5
List<Messaging.SingleEmailMessage > Email_list=new List<Messaging.SingleEmailMessage >();
&
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {message }); (At Line 19)
Will you please explain??
Regards
Pranav Shah
So if the above code works for you then mark it as the best answer
i am getting Error at Line No 5 :
Error: Compile Error: Variable does not exist: opps at line 5 column 20
public class Email_Opportunity
{
public static void email_send(List<Opportunity> opps);
{
for(Opportunity op:opps)
{
if(op.StageName=='Closed Won')
{
System.debug('Email Send Succsessfully');
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
Messaging.SingleEmailMessage();
message.toAddresses = new String[] { 'pranav17shah@gmail.com' };
message.subject = 'Opp Stage Updated';
message.plainTextBody = 'Opportunity Stage Changed to Closed Won';
Messaging.SingleEmailMessage[] messages =new List<Messaging.SingleEmailMessage> {message};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
}
}
}
}
I don't know.
But this code works for me.
And Instead of line 15 and 16
try this
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {message });
And if still it doesn't work then copy my code and execute it.
can anyone pls tell