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...


  1. hi guys,
    my requirment is similar to this, but ineed attachments from visualforce page(alresdy i create and fetech my attachments to that page and as well as emailtemplates also from another visualforce page (i created)
    here my requirement is to send attachments and emailtemplates to selective contact emailids ids)

  2. can anyone know this code please post

    advance thanks guys.