Uh oh!
There was an error while loading. Please reload this page.
Usage Samples: Add Usage Documentation for Email Attachment Download - #110
Usage Samples: Add Usage Documentation for Email Attachment Download#110DuncBegg wants to merge 2 commits into
Conversation
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
Renji (Renji-FR)
commented
May 2, 2023
See #92 (comment) Example: request_message=self._msgraph_request.messages.by_message_id(message_id)
request_attachment=request_message .attachments.by_attachment_id(attachment_id)
query_params=AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetQueryParameters()
request_config=AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
attachment=awaitrequest_attachment .get(
request_configuration=request_config
)
content=attachment.content_bytescontent=base64.b64decode(content)
content=content.decode('ascii') |
How are you getting the value for "attachment_ID" in this scenario? I cannot find any way to pull any information about the attachment other than "hasattachment", which is more a property of a message than an attachment. When I use the ".attachments" property on a mailitem, say, like, "message.attachments.ID", for example, it comes up Nonetype. I know I've authenticated properly, because I am still able to pull data from the body of the email, but cannot pull the attachment. |
Renji (Renji-FR)
commented
May 26, 2023
CommunityHam Hi, I use that: asyncdef_list_attachments(self, message:Message) ->None|list[Attachment]:
query_params=AttachmentsRequestBuilder.AttachmentsRequestBuilderGetQueryParameters(
)
request_config=AttachmentsRequestBuilder.AttachmentsRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
request_message=self._msgraph_request.messages.by_message_id(message.id)
attachments:AttachmentCollectionResponse=awaitrequest_message.attachments.get(
request_configuration=request_config
)
ifattachmentsisnotNoneandattachments.valueisnotNone:
ifattachments.odata_next_linkisnotNone:
passreturnattachments.valueelse:
returnNoneThen use the return value like this: attachments=awaitself._list_attachments(message)
ifattachmentsisNone:
returnNonequery_params=AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetQueryParameters(
)
request_config=AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
request_message=self._msgraph_request.messages.by_message_id(message.id)
forattachmentinattachments:
request_attachment=request_message.attachments.by_attachment_id(attachment.id)
... |
Jussi Hietanen (jussihi)
commented
Sep 17, 2023
Can't you get all the attachments to a single list with single call: attachments= (await (graph_client.users.by_user_id(user_id).messages.by_message_id(message.id).attachments.get())).valuethen you can check if entry is an |
Pls provide a sample showing how to download a file attachment in an email.
eg Say i wanted to download an excel file from my mailbox.