能否通过Outlook REST API的ExtendedProperties设置邮件项头?
Great question—yes, you absolutely can set email headers for Outlook draft items using the Outlook REST API's Extended Properties. This means you can ditch that problematic EWS SOAP call (with its 10-20% failure rate) entirely, which is a huge win for reliability.
How to implement this with the Outlook REST API
- First, you'll need to target the Internet message headers extended property. The property set ID for this is
00062008-0000-0000-C000-000000000046, and the property name isInternetMessageHeaders. It's a multi-valued string property, since email headers are stored as individual key-value string entries (like"X-My-Custom-Header: MySpecialValue"). - When creating or updating a draft, include this extended property in your request body. Here's a simplified example of a PATCH request to update an existing draft:
PATCH /me/messages/{draft-message-id} Content-Type: application/json { "multiValueExtendedProperties": [ { "id": "String {00062008-0000-0000-C000-000000000046} Name InternetMessageHeaders", "value": [ "X-Custom-Header-1: FirstValue", "X-Custom-Header-2: SecondValue" ] } ] }
- A critical note: If you're updating an existing draft, make sure to include any existing headers you want to keep in the
valuearray. The API will overwrite the existing headers with whatever you provide, so omitting existing ones will remove them from the draft.
Why this replaces your EWS SOAP call
The Outlook REST API's extended properties interface maps directly to the same underlying mailbox data that EWS accesses. Setting headers via this method achieves the exact same outcome as your current EWS SOAP call, but without the high failure rate you're encountering. REST endpoints are generally more consistent and reliable for modern integrations, so this switch should resolve your reliability issues.
内容的提问来源于stack exchange,提问作者Michahell

