Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Thursday, 19 February 2015

Send Email using Apex and vf page by using email templates.





Hi friends,


Previously in this post I showed you how we can send emails using Messaging class, but many times we need to send email using email templates in apex code.

So in this post I am using email templates to an send email from apex code:

I am using 2 vf pages and 2 controller in this example:-

  • SendEmailByTemplateVFPage - This is the page from where we are sending Email from template.
  • ClsSendEmailByTemplate - This is controller class of "SendEmailByTemplateVFPage".
  •  SelectTemplate - This is another vf page which is calling from "SendEmailByTemplateVFPage", in this page we are querying all the Email Templates.
  • ClsSelectTemplate - This is controller class of "SelectTemplate".

Here the code:-

Screen Shots:-






Happy Coding...:)

Thanks
Anurag Jain

Tuesday, 11 February 2014

Send email with attachment from Apex class and VF Page in salesforce.





Hi friends,

This post shows how to send Email with Attachment using Apex Controller and VF Page.

I am writing this post because it’s a common requirement to sends emails from salesforce with attachment to clients, contacts etc.

As per my knowledge there are two ways to send email from Apex:-
1.      By using email templates.
2.      By using Messaging class.

Here I am using Messaging class for sending email from apex class:-



Screen shots:-





hope it helps, happy coding...