我已经从收到的电子邮件中复制了(HTML)源代码,只是为了获得该电子邮件的模板/格式,这是我在运行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"}]}}
感谢您的答复。如果您将源代码中包含图像和CSS的电子邮件中的源代码复制到邮件正文中,则可以这样做吗?谢谢
我尚未在邮件正文中使用图片/ css测试过电子邮件,但应该可以使用。如果您遇到任何问题,请在此处报告。如果可行,请考虑赞成以上答案-这样对社区中的其他人也很有用;)