hi all i'm fresher in salesforce and my qustions is get the email field value from object and send a email to the particular email id using a batch apex please help me to solvev
Please use SingleEmailMessage Object to throw email out of salesforce using apex. Please go through below article, this will let you know how to use this object:
Please use SingleEmailMessage Object to throw email out of salesforce using apex. Please go through below article, this will let you know how to use this object:
http://salesforce.stackexchange.com/questions/1243/setting-a-from-address-in-singleemailmessage
Create one generic method in batch apex and pass email id through Parameters.
Hope this helps you!!!
Thanks,
Gaurav
Find the below blog for detail description about sending emails using batch class .
http://forceguru.blogspot.in/2011/03/how-to-send-more-than-10-e-mails.html
http://www.fishofprey.com/2012/03/salesforce-sending-notification-when.html
try bellow code
Thank you
global class emailbatchclass implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC){
{
return database.querylocator('select id,name,email from contact limit 5');
}
global void execute(database.BatchableContext bc , List<sobject> conlist)
{
string body;
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
List<String> sendTo = new List<String>();
for(contact mycontact :conlist)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
sendTo.add(myContact.Email);
mail.setToAddresses(sendTo);
mail.setSubject('URGENT BUSINESS PROPOSAL');
body = 'Mymail body';
mail.sethtmlBody(body);
mails.add(mail);
}
Messaging.sendEmail(mails);
}
global void finish(database.batchblecontext bc)
{
}
}
}
in Developer console what function to write to send an email Please help me
Thankyou