Perform mail merging on a document and return the modified content.
Post
/API/Rest/Documents/Preview
| documentName | The name of the document to preview. |
| emailAddress | The email address of an existing recipient that should be used to resolve the mail merge tags. |
| substitutions | A string dictionary of keys and values to use for substitution in the DynamicTag mail merge arguments. |
EditDocument
No Permission
Invalid email address
Invalid document name
An error occurred attempting to mail merge
Database error
Unknown error
A structure with the document mail merged fields:
{"textBody":"This is the document text","htmlBody":"\u003cp\u003eThis is the html\u003c/p\u003e\u003cbr\u003e\u003cp\u003eWith a link: \u003ca href=\"http://clicks.example.com/Click.aspx?page=003001044085\"\u003eClick for MSN\u003c/a\u003e\u003c/p\u003e","headers":{"From":"support@example.com","To":"\"Joe Blow\" \u003cjoe@example.com\u003e","Reply-To":"support@example.com","Date":"Thu, 14 Feb 2019 14:31:17 -0800","Message-ID":"\u003c0$13794002517401084410$da049470$82931d05@sender.example.com\u003e","Subject":"Simply subjective","RcptTo":"joe@example.com","List-Unsubscribe":"\u003chttp://clicks.example.com/ListUnsub.aspx?MQ=0\u0026V=hiXcXvYIEEcNrNzEA\u003e,\u003cmailto:ListUnsubscribe-0-2889@clicks.example.com\u003e"},"recipientId":9,"emailAddress":"joet@example.com","documentId":3145,"errorMessage":""}
Preview a document.
using System;
using System.Net.Http;
using System.Text;
string url = "https://example.com/API/Rest/Documents/Preview";
string message = "{\"accountName\":\"acme\",\"login\":\"ApiUser\",\"password\":\"YOUR_PASSWORD\",\"documentName\":\"JunkMe\",\"emailAddress\":\"joe@example.com\",\"Substitutions\":{\"RewardAmount\":\"$20\",\"Valid until\":\"5/6/2020\"}}";
// Reuse HttpClient for multiple requests in production code.
using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
request.Content = new StringContent(message, Encoding.UTF8, "application/json");
using (HttpResponseMessage response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
# encoding: utf-8
require 'rest-client'
require 'json'
url = 'https://example.com/API/Rest/Documents/Preview'
args = {'accountName'=>'acme', 'login'=>'ApiUser', 'password'=>'YOUR_PASSWORD', 'documentName'=>'JunkMe2','emailAddress'=>'joe@example.com', 'Substitutions'=>{'RewardAmount'=>'$20', 'Valid until'=>'5/6/2020'}}
response = RestClient.post(url, args.to_json, :content_type => "application/json;charset=utf-8")
puts response
import requests
url = "https://example.com/API/Rest/Documents/Preview"
args = {'accountName':'acme','login':'ApiUser', 'password':'YOUR_PASSWORD', 'documentName':'JunkMe', 'emailAddress':'joe@example.com', 'Substitutions':{'RewardAmount':'$20', 'Valid until':'5/6/2020'}}
headers = {'Content-Type': 'application/json'}
resp = requests.post(url, json=args, headers=headers)
if resp.status_code == 200:
print(resp.text)
curl --request POST --header "Content-Type: application/json" --data '{"accountName":"acme","login":"ApiUser", "password":"YOUR_PASSWORD", "documentName":"JunkMe", "emailAddress":"joe@example.com", "Substitutions":{"RewardAmount":"$20", "Valid until":"5/6/2020"}}' "https://example.com/API/Rest/Documents/Preview"