2015-10-20 178 views
1

有關更多上下文,請參見this thread。在弄清楚如何通過Office 365郵件REST API從消息中檢索ItemAttachments後,我現在遇到了另一個問題:從ItemAttachments中檢索FileAttachments。如何從Office 365郵件REST API中的ItemAttachment檢索FileAttachment?

API指南不包括這一點(據我所知)。當我檢索ItemAttachment時,「HasAttachment」鍵的值爲「true」,但我無法弄清楚如何檢索它。

我(盲目)嘗試了以下的URI:

/api/v1.0/me/messages/{messageid}/Attachments/{itemattachmentid}?$expand=Microsoft.OutlookServices.ItemAttachment/Item /附件

/api/v1.0/me/messages/{messageid}/Attachments/{itemattachmentid}?$expand=Microsoft.OutlookServices.ItemAttachment/Item/Microsoft.OutlookServices.FileAttachment/File

/api/v1.0/me/messages/{messageid}/Attachments/{itemattachmentid}?$ expand = Microsoft.OutlookServices.ItemAttachment/Item/File

顯然我不確定自己在做什麼:P

回答

1

對不起,今天暫不支持。我們會把這個放在我們的產品積壓中。

+0

嗨,這個問題在2.0 api中有沒有更新?即使現在,官方網頁也允許爲特定活動獲取附件。 – sk1pro99

0

我們現在支持API的Beta版本。您可以通過幾種不同的方式從附加的消息或事件中獲取附件。

通過根消息

GET https://outlook.office.com/api/beta/me/messages/[message-id]? 
$expand=Attachments($expand=Microsoft.OutlookServices.ItemAttachment/Item 
($expand=Microsoft.OutlookServices.Event/Attachments)) 

注意擴展:在過去的$expand我用Microsoft.OutlookServices.Event的類型,但你應該改變這種以匹配實際類型的附加項目。對於消息,它將是Microsoft.OutlookServices.Message

實施例響應(截斷)

{ 
    "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAA=", 
    "CreatedDateTime": "2017-02-17T19:59:52Z", 
    "LastModifiedDateTime": "2017-02-17T19:59:53Z", 
    "ChangeKey": "CQAAABYAAABk23L+AKqTR5R9JLmwxOUMAABfVXy6", 
    "Categories": [], 
    "ReceivedDateTime": "2017-02-17T19:59:53Z", 
    "SentDateTime": "2017-02-17T19:59:43Z", 
    "HasAttachments": true, 
    "InternetMessageId": "<[email protected]od.outlook.com>", 
    "Subject": "ItemAttachmentTest", 
    "BodyPreview": "Hello!", 
    "Importance": "Normal", 
    "ParentFolderId": "AQMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMgBjYTliODJhNTIALgAAA6Ii1CwFSf1Ai6F6MypimPkBAGTbcv4AqpNHlH0kubDE5QwAAAIBDAAAAA==", 
    "ConversationId": "AAQkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgAQAMMK8FY8x0SBhvgi8t6QP50=", 
    "ConversationIndex": "AdKJWFYcwwrwVjzHRIGG+CLy3pA/nQ==", 
    "IsDeliveryReceiptRequested": null, 
    "IsReadReceiptRequested": false, 
    "IsRead": false, 
    "IsDraft": false, 
    "WebLink": "https://outlook.office365.com/owa/?ItemID=AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L%2BAKqTR5R9JLmwxOUMAAAAAAEMAABk23L%2BAKqTR5R9JLmwxOUMAABfQr6jAAA%3D&exvsurl=1&viewModel=ReadMessageItem", 
    "InferenceClassification": "Focused", 
    "UnsubscribeData": [], 
    "UnsubscribeEnabled": false, 
    "Body": { 
    "ContentType": "HTML", 
    "Content": "Hello!" 
    }, 
    "Sender": { 
    "EmailAddress": { 
     "Name": "Jason Johnston", 
     "Address": "[email protected]" 
    } 
    }, 
    "From": { 
    "EmailAddress": { 
     "Name": "Jason Johnston", 
     "Address": "[email protected]" 
    } 
    }, 
    "ToRecipients": [ 
    { 
     "EmailAddress": { 
     "Name": "Adele Vance", 
     "Address": "[email protected]" 
     } 
    } 
    ], 
    "CcRecipients": [], 
    "BccRecipients": [], 
    "ReplyTo": [], 
    "MentionsPreview": null, 
    "Flag": { 
    "FlagStatus": "NotFlagged" 
    }, 
    "Attachments": [ 
    { 
     "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAABEgAQAE7xPNscnYFJmjqkGK0AjJc=", 
     "LastModifiedDateTime": "2017-02-17T19:59:35Z", 
     "Name": "Test appt with attachments!", 
     "ContentType": "message/rfc822", 
     "Size": 33358, 
     "IsInline": false, 
     "Item": { 
     "Id": null, 
     "CreatedDateTime": "2017-02-17T19:59:52Z", 
     "LastModifiedDateTime": "2017-02-17T19:59:52Z", 
     "OriginalStartTimeZone": "Eastern Standard Time", 
     "OriginalEndTimeZone": "Eastern Standard Time", 
     "iCalUId": "040000008200E00074C5B7101A82E00800000000D066332D2E89D201000000000000000010000000DAB182D13FA80846BA7983D8064016CC", 
     "ReminderMinutesBeforeStart": 0, 
     "IsReminderOn": false, 
     "HasAttachments": true, 
     "Subject": "Test appt with attachments!", 
     "Importance": "Normal", 
     "Sensitivity": "Normal", 
     "IsAllDay": false, 
     "IsCancelled": false, 
     "IsOrganizer": true, 
     "ResponseRequested": false, 
     "ShowAs": "Busy", 
     "Type": "SingleInstance", 
     "Body": { 
      "ContentType": "HTML", 
      "Content": "Hello!" 
     }, 
     "Start": { 
      "DateTime": "2017-02-17T17:00:00.0000000Z", 
      "TimeZone": "UTC" 
     }, 
     "End": { 
      "DateTime": "2017-02-17T17:30:00.0000000Z", 
      "TimeZone": "UTC" 
     }, 
     "Location": { 
      "DisplayName": "" 
     }, 
     "Organizer": { 
      "EmailAddress": { 
      "Name": "Jason Johnston", 
      "Address": "[email protected]" 
      } 
     }, 
     "Attachments": [ 
      { 
      "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAACEgAQAE7xPNscnYFJmjqkGK0AjJcSABAAAucTv00RHEqhT3zxzdeBkg==", 
      "LastModifiedDateTime": "2017-02-17T17:53:20Z", 
      "Name": "OutlookSDKTest.log", 
      "ContentType": "application/octet-stream", 
      "Size": 5850, 
      "IsInline": false, 
      "ContentId": "[email protected]", 
      "ContentLocation": null, 
      "ContentBytes": "UmF3IElk..." 
      }, 
      { 
      "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAACEgAQAE7xPNscnYFJmjqkGK0AjJcSABAASt-usjVlxUufvpCupiLncA==", 
      "LastModifiedDateTime": "2017-02-17T17:11:28Z", 
      "Name": "OutlookWebAddIn1.xml", 
      "ContentType": "application/xml", 
      "Size": 12015, 
      "IsInline": false, 
      "ContentId": "[email protected]", 
      "ContentLocation": null, 
      "ContentBytes": "77u/PD94..." 
      } 
     ] 
     } 
    } 
    ] 
} 

通過附件ID

GET https://outlook.office.com/api/beta/me/messages/[message-id]/ 
attachments/[attach-id]?$expand=Microsoft.OutlookServices.ItemAttachment/Item 

實施例響應(截斷)

{ 
    "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAABEgAQAE7xPNscnYFJmjqkGK0AjJc=", 
    "LastModifiedDateTime": "2017-02-17T19:59:35Z", 
    "Name": "Test appt with attachments!", 
    "ContentType": "message/rfc822", 
    "Size": 33358, 
    "IsInline": false, 
    "Item": { 
    "Id": null, 
    "CreatedDateTime": "2017-02-17T19:59:52Z", 
    "LastModifiedDateTime": "2017-02-17T19:59:52Z", 
    "OriginalStartTimeZone": "Eastern Standard Time", 
    "OriginalEndTimeZone": "Eastern Standard Time", 
    "iCalUId": "040000008200E00074C5B7101A82E00800000000D066332D2E89D201000000000000000010000000DAB182D13FA80846BA7983D8064016CC", 
    "ReminderMinutesBeforeStart": 0, 
    "IsReminderOn": false, 
    "HasAttachments": true, 
    "Subject": "Test appt with attachments!", 
    "Importance": "Normal", 
    "Sensitivity": "Normal", 
    "IsAllDay": false, 
    "IsCancelled": false, 
    "IsOrganizer": true, 
    "ResponseRequested": false, 
    "ShowAs": "Busy", 
    "Type": "SingleInstance", 
    "Body": { 
     "ContentType": "HTML", 
     "Content": "Hello!" 
    }, 
    "Start": { 
     "DateTime": "2017-02-17T17:00:00.0000000Z", 
     "TimeZone": "UTC" 
    }, 
    "End": { 
     "DateTime": "2017-02-17T17:30:00.0000000Z", 
     "TimeZone": "UTC" 
    }, 
    "Location": { 
     "DisplayName": "" 
    }, 
    "Organizer": { 
     "EmailAddress": { 
     "Name": "Jason Johnston", 
     "Address": "[email protected]" 
     } 
    }, 
    "Attachments": [ 
     { 
     "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAACEgAQAE7xPNscnYFJmjqkGK0AjJcSABAAAucTv00RHEqhT3zxzdeBkg==", 
     "LastModifiedDateTime": "2017-02-17T17:53:20Z", 
     "Name": "OutlookSDKTest.log", 
     "ContentType": "application/octet-stream", 
     "Size": 5850, 
     "IsInline": false, 
     "ContentId": "[email protected]", 
     "ContentLocation": null, 
     "ContentBytes": "UmF3IElk..." 
     }, 
     { 
     "Id": "AAMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMmNhOWI4MmE1MgBGAAAAAACiItQsBUn9QIuhejMqYpj5BwBk23L_AKqTR5R9JLmwxOUMAAAAAAEMAABk23L_AKqTR5R9JLmwxOUMAABfQr6jAAACEgAQAE7xPNscnYFJmjqkGK0AjJcSABAASt-usjVlxUufvpCupiLncA==", 
     "LastModifiedDateTime": "2017-02-17T17:11:28Z", 
     "Name": "OutlookWebAddIn1.xml", 
     "ContentType": "application/xml", 
     "Size": 12015, 
     "IsInline": false, 
     "ContentId": "[email protected]", 
     "ContentLocation": null, 
     "ContentBytes": "77u/PD94..." 
     } 
    ] 
    } 
} 
相關問題