1

We have a limitation using Visualforce email template. VF Email Template can't be used for mass email.

I am look for the ways how this can be achieved.

I have created a visalforce email template which displays the opportunity records based on Used If in the tabular form on the email.

Next is i need to send this email template to all the users on every last week of the month.When the mail is sent it has to capture the User id and display the records.

My question is how to send an mass email using Visualforce email template to all the user on the last week of the month.

3 Answers 3

0

Not the exact solution you are looking but a workaround might help From the doc Visualforce email templates cannot be used for mass email

So - how to get around this?

  1. You will need to use a custom field, Workflow email alerts + field update In your trigger or VF controller,
  2. when the affected record(s) are ready to have their mass email sent, mark custom field is_ready_for_mass_email__c to true
  3. The workflow will execute upon the batch of updated records
  4. The object's fields can be used as merge fields for the VF template
  5. The workflow then uses a field update to set is_ready_for_mass_email__c to true

Of course, the recipient will need to be a field of type Email in your object so the email alert has somewhere to send the message to.

0

I have implemented something similar to this using SingleEmailMessage instead of MassEmailMessage. My requirement was to send Emails to all C-Level executives every Monday morning 9AM with all open priority cases within last 180 days.

The solution is somewhat complex and not simple as it looks. For this I have used 2 workflow rules(1 to trigger the email and other time based wf to update the run time,count Trigger (before event), Visualforce Email template with component to fetch the data. I created a new contact which will maintain the run time for the emails to get triggered.

2
  • If there are few number of users we can use singleEmailMessage but in our case we have to send mail to around 200+users so we will be hitting the limits
    – user7447
    Commented Jan 27, 2016 at 4:48
  • We have added a new picklist in User object for Daily/Weekly emails. So it works for all the users in the org who have selected a value for the picklist field.
    – Anant
    Commented Jan 28, 2016 at 5:10
0

Here is the process flow how i achieved 1.Created a custom Checkbox field on the User Object. 2.Wrote an Apex class to invoke the scheduler and in the execute method few line of code to fetch the user(to whom the mail has to be sent were stored in a public group) from the public group and set the check box field to true-- batch apex. 3.Scheduled the class to run on a particular day of the month. 4.Workflow email alert+field update(to uncheck the checkbox field).

You must log in to answer this question.

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