As per my understaing you want to write send email after Tranaction record created with type in "deposit,withdrawn".
You can create workflow in Salesforce to send email alert. Here link to create workflow https://help.salesforce.com/articleView?id=workflow_rules_new.htm&type=0
I have a 4 custom Fields Customer Name ; Transcation type; Transcation Amount; Email Id;
Whenever Transcation Type(Picklist values ---> Deposit & Withdrawn) changes. Email should be sent to the given mail id in Email field. & If Transcation Type changes then Transcation AMount also should be change i.e; If it is Deposit then Amount should be Added where Transcation Type = withdrawn then AMount be Subtracted
Use below code in your Visualforce page button action in apex method.
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(myContact.Email);
mail.setToAddresses('nawaleprakash@gmail.com');
mail.setSenderDisplayName('Test Email');
mail.setSubject('URGENT BUSINESS PROPOSAL');
String body = 'Dear ' + myContact.FirstName + ', ';
body += 'Welcome to Salesforce';
mail.setHtmlBody(body);
mails.add(mail);
Messaging.sendEmail(mails);
You can create workflow in Salesforce to send email alert.
Here link to create workflow
https://help.salesforce.com/articleView?id=workflow_rules_new.htm&type=0
by using vf i required @Prakash Nawale
Can you please explain your complete use case.
Customer Name ;
Transcation type;
Transcation Amount;
Email Id;
Whenever Transcation Type(Picklist values ---> Deposit & Withdrawn) changes. Email should be sent to the given mail id in Email field.
& If Transcation Type changes then Transcation AMount also should be change i.e; If it is Deposit then Amount should be Added where Transcation Type = withdrawn then AMount be Subtracted
Use below code in your Visualforce page button action in apex method.
FYI:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
Everything Ok But I'm not receving the mail.setHtmlBody(body); to email field When i saved the Program
Can you check Email Deliverability from Setup=>Email Administration.
Make sure Access level equals All Email.
Please let me know will it works or not.
Regards,
Prakash