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
Rafal buchRafal buch 

how to mail merge using using the API

Hello, 

I use the SF API to query for distribution lists, contacts, and mail templates to provide custom mass mail capability. 

The next step is to add support for personalization, ie: Hello  {!Contact.Name} or {!Lead.Name} or {!User.Name}. 

I found connection.Merge(mergeRequest[]) method, but not quite sure if this is what I am looking for, and google is not giving me anything obvious so far.  

Can you steer me in the right direction? 

I want to take a email template, and merge in contact, user etc information, and get a personalized email template string back, so I could pass it to my custom mail program. 

thanks! 
Jean-NoelJean-Noel
You can use email template and use the API to send all emails using that template.
Rafal buchRafal buch
hi, 

I am using email templates, and already sending emails using those templates. I need to figure out how to I can perform the mail merge _within my program_ 
Jean-NoelJean-Noel
When you send an email, there is a property TemplateId, you'll need to pass the Id of your template.
Rafal buchRafal buch
Hi, 

sorry i am not sure what you are talking about..  Here are my application steps 

1. Retrieve templates using SF api
2. retrieve distribution lists using SF api
3. retrieve contacts (based on selected distribution list by user) using SF api
4. email each contact the contents of the email template (using my custom application)

Each retrieved template gives me a string of the contents html.  That string includes text such as {!Contact.Name}. I need a way to replace that with an actual name of a contact. 

This is the part I need to do programmatically right now.  
Rafal buchRafal buch
steps 1-4 are currently working, I am researchign how to achieve the next step, which is merging contacts with mail templates 
Rafal buchRafal buch
to clarify, I am not using aphex to do this.. I am using SF API to get data, but the code runs on .Net platform