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
SURESH MINGANISURESH MINGANI 

how to write a visual force program when transaction type deposit/withdrawn then Email should be sent

HI , I'm New to sfdc please help me
Prakash NawalePrakash Nawale
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
SURESH MINGANISURESH MINGANI
I don't want to send through workflow.
by using vf i required @Prakash Nawale
Prakash NawalePrakash Nawale
Hi Suresh,

Can you please explain your complete use case.

 
SURESH MINGANISURESH MINGANI
 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
 
SURESH MINGANISURESH MINGANI
i Have Created vf
Prakash NawalePrakash Nawale
Hi Suresh,

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);

FYI:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
SURESH MINGANISURESH MINGANI
Hi Prakash Nawale,
Everything Ok But I'm not receving the mail.setHtmlBody(body); to email field When i saved the Program
Prakash NawalePrakash Nawale
Hi Suresh,

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