You need to sign in to do that
Don't have an account?
Nahian Islam
On click of a button(which is in a Contract Object), it should send mail(including ccTo) to people.
The email to be sent will have the custom field values (Contract Name, Contract Number) in the body/subject of the mail
What I have done:
Created an apex class for the email:
public class send_Email
{
public void sendMailTo()
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'nahian.islam@gmail.com'};
String[] ccAddresses = new String[] {'nahian.islam@gmail.com'};
email.setToAddresses(toAddresses);
email.setCcAddresses(ccAddresses);
email.setSubject('< Contract Number>');
String mailBody = 'Dear Nahian,'+
'<br><br>'+
'<br><br>This is a test mail'+
'<br><br>'Please approve this contract'+
'<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');
}
}
}
Created Visualforce Page:
<apex:page controller="send_Email" action="{!sendMailTo}"> Email Sent Successfully! </apex:page>
I do not know how to fetch the Contract name from where the user is clicking the button.
PLEASE HELP
What I have done:
Created an apex class for the email:
public class send_Email
{
public void sendMailTo()
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'nahian.islam@gmail.com'};
String[] ccAddresses = new String[] {'nahian.islam@gmail.com'};
email.setToAddresses(toAddresses);
email.setCcAddresses(ccAddresses);
email.setSubject('< Contract Number>');
String mailBody = 'Dear Nahian,'+
'<br><br>'+
'<br><br>This is a test mail'+
'<br><br>'Please approve this contract'+
'<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');
}
}
}
Created Visualforce Page:
<apex:page controller="send_Email" action="{!sendMailTo}"> Email Sent Successfully! </apex:page>
I do not know how to fetch the Contract name from where the user is clicking the button.
PLEASE HELP
Object: Contract, Custom Field: Contract_num__c
Can you help with the exact syntax on how I can call this current contract num from where the user is clicking the button?
AccountName = [SELECT name
FROM Contract__c
WHERE Contract__c =: ApexPages.currentPage().getParameters().get('id')]
This is how bad I can guess :(
id=ApexPages.currentPage().getParameters().get('id');
List<sobject> cs=new List<Sobject>();
cs=[select fields from object where id=:cseid limit 1];
place your field like cs.queried field.
Hi,
I tried this. But Unable to fetch values. Please help!
public class send_DemandEmail
{
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@gmail.com'};
String[] ccAddresses = new String[] {'pritesh.curicad@gmail.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');
}
}
}