{{ message }}
Usage Samples: Add Usage Documentation for Email Attachment Download - #110
Open
DuncBegg wants to merge 2 commits into
Open
Usage Samples: Add Usage Documentation for Email Attachment Download#110DuncBegg wants to merge 2 commits into
DuncBegg wants to merge 2 commits into
Conversation
DuncBegg
requested review from
Michael Mainer (MIchaelMainer),
Philip Gichuhi (Ndiritu),
silaskenneth (SilasKenneth),
Andrew Omondi (andrueastman),
Darrel (darrelmiller),
DeVere Dyett (ddyett),
Samwel K. (samwelkanda),
Shem Ogumbe (shemogumbe) and
Mustafa Zengin (zengin)
as code owners
February 21, 2023 06:40
Contributor
|
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 = await request_attachment .get(
request_configuration=request_config
)
content = attachment.content_bytes
content = 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. |
|
CommunityHam Hi, I use that: async def _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 = await request_message.attachments.get(
request_configuration=request_config
)
if attachments is not None and attachments.value is not None:
if attachments.odata_next_link is not None:
pass
return attachments.value
else:
return NoneThen use the return value like this: attachments = await self._list_attachments(message)
if attachments is None:
return None
query_params = AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetQueryParameters(
)
request_config = AttachmentItemRequestBuilder.AttachmentItemRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
request_message = self._msgraph_request.messages.by_message_id(message.id)
for attachment in attachments:
request_attachment = request_message.attachments.by_attachment_id(attachment.id)
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.