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
Nahian IslamNahian Islam 

I want to create a onclick button email trigger. On clicking the button, it should send a mail to specific users. The email should also have the values of current required fields. Please assist

Panduranga GollaPanduranga Golla
It may help you ---
https://developer.salesforce.com/forums/?id=906F00000008mT4IAI
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/
Nahian IslamNahian Islam

Hi,

I went through the links but probably failed to get what I was looking for as I'm an amateur.

To be more clear. I have an Object:Contract. It has a button on that object header. What would be the syntax for fetching the current Contract_Name__c from where the button was clicked?

Please help !

It would be easier for me if you could help me with the syntax.

Nahian IslamNahian Islam

Guys need urgent Help!

public class send_RFQDemandEmail
{
     public static list<Contract_Line_Detail__c> con;
     string id{get;set;}
     

    public void sendMailTo()
    {  
        
        con = [select Account_Name_del__c from Contract_Line_Detail__c where id =: ApexPages.currentPage().getParameters().get('id')];
      
        
        
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
      
        String[] toAddresses = new String[] {'nahian.islam@fci.com'};
        String[] ccAddresses = new String[] {'pritesh.curicad@fci.com'};
      
        email.setToAddresses(toAddresses);
        email.setCcAddresses(ccAddresses);
        
        email.setSubject('Next RFQ Demand is Available' +  con);
      
        String mailBody = 'Dear Nahian,'+
                  '<br><br>'+
                  '<br><br>This is a test mail'+
                  '<br><br>If you are recieving this, it means HTML Body is working fine'+
                  '<br><br>This is a test mail'+
                  '<br><br>'+
                  '<br><br>Regards,'+
                  '<br><br>SFDC';

        email.setHTMLBody(mailBody);        
              
      
        try
        {
            
            Messaging.reserveSingleEmailCapacity(1);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
         
        }
      
        catch(Exception e)
        {
            system.debug('Email limit exceeded');
        }  
          
          
    }
    
}


This code is unable to fetch the account name of the existing page from where the button is being clicked.. Please help