0

I want a email template which will have text like this

Dear {contact.Name}

Thanks for approaching us for product {SR.product.Name}. we have reviewed your request and would like to correspond with you using {contact.Phone} .

SR is a custom object here.

Thanks, {user.Name} {user.title} {user.Department}

i want to call this template using a custom controller means these is a button on a VF page . on clicking this, it will call this template and send a email to some email address.

My question here is which email template i should use here (custom or VF template) and how to pass all these objects (Contact,SR,User) data to that template.

Any help regarding this would be great.

Thanks,

2 Answers 2

0

if you are using code (Messaging.singleEmailMessage) to send the email using the template just use an HTML / Plain text email template and set the targetObjectID to the contact and the whatID to the SR record.

3
  • Please note that the limit for single email messages is 2000 per day.
    – raffters
    Jun 4, 2015 at 3:03
  • and what about user ?? how will I send the user id? Jun 4, 2015 at 7:31
  • @SachinKadian Use the global variable $User in your template to access values from the running user
    – cropredy
    Jun 5, 2015 at 1:25
0

For your instance you need a vf template to be created. a page for your buttons logic and a controller. Your controller should contain Messaging.SingleEmailMessage().

your template should look like this> Dear {!relatedTo.Contact.Name} {!relatedTo.SR.Product.Name} and Thanks {!recipient.User.Name} {!recipient.User.Name}

Hope This answers your question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .