function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rivereridanusrivereridanus 

Include link or button to Mass Mail Merge on custom visualforce page

I am trying to figure out how to create a link or button on the custom visualforce pages that override the SF default home pages for Contacts, Accounts, and Leads. The visualforce home pages are just an extended list of all records in that object since my users were getting confused by the original default home page.  

We just got XMM (Extended Mail Merge) enabled in our org, and the only way to get to it seems to be via the default home page- but we don't use those.  I'd like to find a way to put a button or link on the visualforce home page- or at least provide some way for my users to be able to get to it. Anyone have any thoughts or know anything about this?  Any comments are appreciated! 
ShashankShashank (Salesforce Developers) 
You can probably try getting the URL of the mass email or mail merge link and create it as a hyperlink in your VF page.
Devon SacksDevon Sacks

You could always just use the following code in the button, I do not want the contacts to know who is getting emailed so I am adding their emails to the Bcc field. In doing this Salesforce requires that you have a "to field". I am populating the additional to field with a donot reply email so that the system will take the code.
This will work for any object list view just change the object from contact to your desired object assuming it has an Email field.

Behavior is Execute JavaScript
Display Type List button
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var emailAddresses = ''; 
var records = {!GETRECORDIDS($ObjectType.Contact)}; 
if (records[0] == null) {
    alert("Please select at least one record to update.");
} else {
for(var c = 0; c < records.length; c++) 

var contactRecord = sforce.connection.query("SELECT Email FROM Contact WHERE Id ='"+ records[c] 
+"'"); 

emailAddresses = emailAddresses + contactRecord.records.Email + ";"; 

location.replace('/email/author/emailauthor.jsp?retURL=/{!Contact.Id}&rtype=003&p24=someemail@somecompany.com&template_id=(your_template_ID)&p5='+emailAddresses);
}