我允许用户使用 Microsoft Graph API 使用其 Outlook 帐户发送电子邮件,但它似乎在另一端创建了多个线程。
使用 Mailgun API 发送用户电子邮件时,我能够传递引用上一条消息 Message-ID 的 In-Reply-To 消息标头,并且线程由另一端的客户端(Outlook/Gmail 等)正确集群
但是当使用 Microsoft Graph API 时,我尝试传递 In-Reply-To 并且它不被 API 接受
graph_url = 'https://graph.microsoft.com/v1.0'
headers = {
'User-Agent': 'api/1.0',
'Authorization': f'Bearer {outlook_token}',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
# Create recipient list in required format.
recipient_list = [{'emailAddress': {'name': name, 'address': address}} for name, address in recipients]
reply_to_list = [{'emailAddress': {'name': name, 'address': address}} for name, address in reply_to]
# Create email message in required format.
email_object = {
'message': {
'subject': subject,
'body': {
'contentType': content_type,
'content': body
},
'toRecipients': recipient_list,
'replyTo': reply_to_list,
'attachments': [{
'@odata.type': '#microsoft.graph.fileAttachment',
'contentBytes': b64_content.decode('utf-8'),
'contentType': mime_type,
'name': file.name
}],
'internetMessageHeaders': [
{
"name": "In-Reply-To",
"value": in_reply_to
},
]
},
'saveToSentItems': 'true'
}
# Do a POST to Graph's sendMail API and return the response.
request_url = f'{graph_url}/me/microsoft.graph.sendMail'
response = requests.post(url=request_url, headers=headers, json=email_object)
https://docs.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0
我得到以下回复:
{
"error": {
"code": "InvalidInternetMessageHeader",
"message": "The internet message header name 'in-Reply-To' should start with 'x-' or 'X-'.",
"innerError": {
"request-id": "7f82b9f5-c345-4744-9f21-7a0e9d75cb67",
"date": "2019-05-03T04:09:43"
}
}
}
有没有办法让收件人客户在同一个线程中发送电子邮件?