+ Start a Discussion
Brijesh KumarBrijesh Kumar 

how to use this email service

Hi
I craete an email services.But I don't know how to use this email service.
 
My problem is, i want to create a button that send an email.when i click button it opens a visual force template.
then send an email.
 
 
Can you suggest me how can develop this.
 
please give me some idea about this.
 
Thanks & Regards
Brijesh Kumar Baser
RickyGRickyG
BKB -

This exact topic is covered in Chapter 13 of the new Developer's Guide to the Force.com Platform.  You can get this book as part of the overall Force.com library here.

Hope this helps.
Brijesh KumarBrijesh Kumar
Hi
I have tried that book.I learned chapter 13 for email services.
I want to send an email by using visualforce email template.

Messaging.SingleEmailMessage mail =
new Messaging.SingleEmailMessage();
mail.setToAddresses( new String[]
{ jobApplication.Candidate__r.Email__c });
mail.setTemplateId(your_template_id);
mail.setwhatId(JobApplicationId);

But i am not understand about mail.setwhatId(JobApplicationId).

when i am not using this line i get an exception like this


System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing targetObjectId with template

How can i solve this exception.

Please help me

Thanks
Brijesh Kumar Baser
RickyGRickyG
The JobApplicationID is a valid ID for a Job Application.  It looks like this value is not set.  Are you sure this variable contains a value?
Brijesh KumarBrijesh Kumar
Hi RickyG
My question is not depend on JobApplicationId .
mail.setwhatId();

what value passed in this method.
I use a Lead detail page.Inside there i use s-controll which is URL based.This URL points to visualforce page.
In this visual force page i wants to call inbuilt visualforce mail template.

I use
Messaging.SingleEmailMessage mail =
new Messaging.SingleEmailMessage();
mail.setToAddresses( new String[]
{ jobApplication.Candidate__r.Email__c });
mail.setTemplateId(your_template_id);
mail.setwhatId();
what should i pass in this method to call visualforce Email template.
Thanks
Brijesh Kumar baser