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";
    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,
                        "__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) {

How do I need to format the additionalheaders attribute to set the content-type header correctly? Thanks.

  • A 2 minute search got me back here on StackOverflow: sharepoint.stackexchange.com/questions/150833/… – Danny '365CSI' Engelman Apr 4 '17 at 8:54
  • Yes, I found that as well. It's what led me to write the content-type section the way I did. If you look through the comments on the answer, you will see that the original poster had the same issue I have... that no matter what content-type was sent it was still defaulting to text/html. – FolcoTook Apr 4 '17 at 15:11
  • Since you are after a structured message (you say you need it for another service) why don't you put the data in the Header metadata.. – Danny '365CSI' Engelman Apr 4 '17 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.