We’re tracking emails that we send using the Sharepoint API. What we’re doing is adding a transparent pixel that’s hosted on our server, and the request tells us that the emails was opened. We want to register the opening by user, and for that, the URL of the image has a code as a query parameter, for example:
http://our-server.com/image.png?email_id=123
This way we know that the email with ID 123 was opened.
For this, we must send a different email body to each address, that’s one email code per user, but I’m not sure if the Sharepoint API will allow us to do that in one call. This is what it looks like rigth now:
function _SPSendEmail(
siteUrl: string,
token: string,
emails: string[],
html: string,
subject: string,
senderEmail: string
) {
const spEndpointUrl = `${siteUrl}/_api/SP.Utilities.Utility.SendEmail`;
const body = JSON.stringify({
properties: {
__metadata: {
type: 'SP.Utilities.EmailProperties',
},
From: senderEmail,
To: {
results: emails,
},
Body: html,
Subject: subject,
},
});
return fetch(spEndpointUrl, {
method: 'post',
headers: {
Accept: 'application/json;odata=verbose',
'Content-Type': `application/json;odata=verbose`,
Authorization: 'Bearer ' + token,
},
body,
});
}
As you can see, we can pass an array of emails, but only a string for the body. Is there a way to send multiple email bodies in this call?
If not, is there a way to send a dynamic-content email using the API?