I'm using the SendEmail JavaScript utility and it's working except that I'm getting the email as HTML instead of plain text (which is what I need to process the body correctly for another service). I'm sure I'm missing something obvious, but I can't seem to figure out what. Here is my sendEmail function:
function sendEmail(subject,body) {
appweburl = "https://company.sharepoint.com/sites/sitename";
var urlTemplate = appweburl + "/_api/SP.Utilities.Utility.SendEmail";
$.ajax({
contentType: 'application/json',
url: urlTemplate,
type: "POST",
data: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'From': 'address@company.com',
'To': { 'results': ['otheraddress@company.com'] },
'Body': body,
'Subject': subject,
"AdditionalHeaders":
{"__metadata":
{"type":"Collection(SP.KeyValue)"},
"results":
[
{
"__metadata": {
"type": 'SP.KeyValue'
},
"Key": "Content-Type",
"Value": 'text/plain; charset=utf-8',
"ValueType": "Edm.String"
}
]
}
}
}
),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
var result = data.d.results;
var i = result.length;
},
error: function (err) {
alert(JSON.stringify(err));
}
});
}
How do I need to format the additionalheaders attribute to set the content-type header correctly? Thanks.