mail.send 不接受 HTML/ CSS 代码

mail.send is not accepting HTML/ CSS code

我从收到的电子邮件中复制了 (HTML) 源代码只是为了得到该电子邮件的 template/format,这是我在 [=34= 时收到的错误消息] API:

Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {
  "error": {
    "code": "BadRequest",
    "message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
    "innerError": {
      "date": "2020-12-02T17:01:05",
      "request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d",
      "client-request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d"
    }
  }
}

我已经使用 HTML 测试了基本命令,例如将文本设为粗体和换行,这些命令都有效,但是任何更复杂的命令我都会收到错误消息。

更新** 谢谢你们的回复,我正在使用的调用如下所示:

{
  "message": {
    "subject": "[Subject]",
    "body": {
      "contentType": "HTML",
      "content": "[Email Body Content]"
    },
    "toRecipients": [
      {
        "emailAddress": {
          "address": "[Email Address]"
        }
      }
    ],
    "internetMessageHeaders":[
      {
        "name":"x-custom-header-group-name",
        "value":"Nevada"
      },
      {
        "name":"x-custom-header-group-id",
        "value":"NV001"
      }
    ]
  }
}

**另一个更新**在将内容类型更改为 text/html 时收到此错误:

Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 415
HTTP Response Content: {"error":{"code":"RequestBodyRead","message":"A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'Microsoft.OData.ODataMediaType, Microsoft.OData.ODataMediaTyp...' matches the content type 'text/plain; charset=utf-8'."}}

注意我也尝试过 text/plain 作为内容类型。

谢谢

好的,我尝试了上面的负载(只是更新了电子邮件地址)并使用 Microsoft Graph Explorer 进行了测试。它对我有用:)

这是有效载荷:

{"message":{"subject":"[Subject]","body":{"contentType":"HTML","content":"[Email Body Content]"},"toRecipients":[{"emailAddress":{"address":"test@domain.onmicrosoft.com"}}],"internetMessageHeaders":[{"name":"x-custom-header-group-name","value":"Nevada"},{"name":"x-custom-header-group-id","value":"NV001"}]}}

这是快照: