python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Attachments more than 4 mb

Open Akishev23 opened this issue 5 years ago • 5 comments

Hello,

while i'm trying to attach such files to my message, getting an error requests.exceptions.HTTPError: 413 Client Error: Request Entity Too Large for url: https://graph.microsoft.com/v1.0/me/sendMail

How to handle?

Akishev23 avatar Aug 26 '20 22:08 Akishev23

For the moment is not posible, use the outlook protocol to send big attachments

alejcas avatar Aug 29 '20 07:08 alejcas

Even when you aren't automating it, and you are going into the web application or desktop application, you can't attach them

id-hkj avatar Oct 21 '21 17:10 id-hkj

Any update to this? I have my protocol set as MSGraphProtocol(api_version='beta') per the instructions in the readme for files above 4mb and am still receiving an error

aefruswg avatar Aug 30 '22 21:08 aefruswg

https://docs.microsoft.com/en-us/graph/api/attachment-createuploadsession?view=graph-rest-1.0&tabs=http

https://docs.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http

https://docs.microsoft.com/en-us/graph/known-issues#attaching-large-files-to-messages

I do not think sendMail is the endpoint you want to hit for large files.

BlueSideStrongSide avatar Aug 30 '22 21:08 BlueSideStrongSide

I have got this working by calling .save_message() prior to adding the attachment and it looks like it is working. You might want to give this a try. It looks like this way it crates a draft and then uploads the attachment to draft and then sends it.

I have also raised an issue asking whether this is the correct approach to send mails with large attachment size here: https://github.com/O365/python-o365/issues/841

nachiketrss avatar Sep 23 '22 16:09 nachiketrss

This is the correct approach but it's not documented anywhere

alejcas avatar Oct 06 '22 13:10 alejcas

@janscas hopefully that wording is good enough, otherwise I can revise. Should allow this issue and related ones to be closed?

kwilsonmg avatar Oct 09 '23 17:10 kwilsonmg

@janscas hopefully that wording is good enough, otherwise I can revise. Should allow this issue and related ones to be closed?

sure

alejcas avatar Oct 10 '23 07:10 alejcas