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

Send message with big attachment

Open Krukosz opened this issue 3 years ago • 3 comments

Found PR: https://github.com/O365/python-o365/pull/633

There's no any documentation about how to use it properly. I googled a lot and on one website scheme was:

  • create message
  • save it as a draft
  • add attachments with createUploadSession
  • send it

So i replicated this logic and wrote code:

            m = self.account.new_message()
            m.to.add(send_to)
            m.subject = subject
            m.body = body
            m.save_draft()
            m.attachments.add(attachments)
            m.attachments._update_attachments_to_cloud()
            m.send()

It works, but if it's a correct usage of sending big files? Method _update_attachments_to_cloud() has description that should not be used for non-draft messages

Krukosz avatar Apr 30 '22 18:04 Krukosz

Don’t call _update_attachments_to_cloud() use save_draft() instead.

save draft will call update attachments to cloud.

alejcas avatar May 04 '22 11:05 alejcas

So, the correct way is: add attachments first and then call save_draft() which will call uploadSession and finally send it?

Krukosz avatar May 04 '22 11:05 Krukosz

That should do it

alejcas avatar May 04 '22 11:05 alejcas