question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline images not recognized as attachment

See original GitHub issue

My code basically looks like this:

    for att in message.attachments:
            att.save(att_path)

This recognizes all attachments, including inline images, and adds them to a folder. But this only works if the e-mail has actual separate attachments (i.e. you see the paperclip). If the email ónly contains inline image (pasted images, company logo’s) it won’t add any attachments.

If I had a if message.has_attachment() in my code this would make sense, but I don’t. How do I fix this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
janscascommented, Jul 29, 2019

Ok, I’ve found the issue.

The Graph docs says that the property ‘hasAttachments’:

Indicates whether the message has attachments. This property doesn’t include inline attachments, so if a message contains only inline attachments, this property is false. To verify the existence of inline attachments, parse the body property to look for a src attribute, such as .

Ok. so:

  1. When creating the message instance, if the ‘hasAttachments’ property informed by the server is False, the O365 library will have to inspect the body (in case it’s html) and check if there are img tags with source that starts with ‘cid:’.
  2. If there’s something then change the ‘hasAttachments’ to True.

With these steps It should work.

1reaction
aufbakanleitungcommented, Jul 29, 2019

Here is an e-mail with just 3 inline images: just inline images

Here is that same e-mail with one more image (hackerman.png) added as an attachment: inline and attachment

So now it suddenly recognizes all attachments, incl inline images. So it really seems to me that there is some kind of check for attachments in Python O365 that is causing this behavior. Unless of course Azure O365 is handling e-mails with attachments differently than those without.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embeded/Inline pictures not showing up - Microsoft Community
Embeded/Inline pictures not showing up. Some of my emails from companies that I've received today, the pictures won't load.
Read more >
Inline images are no longer showing, it only has text saying ...
So everything looks great. When the message is sent, the inlined image is converted to an attachment.
Read more >
Image attachments are not displayed inline in wiki renderer ...
Problem. Image attachments do not display inline in wiki renderer fields when using the wiki markup such as !image.png! in a JIRA issue....
Read more >
Gmail attachments and inline images are not included in the ...
The email has both an inline image file in the body, and a file attachment. I want to put the full email into...
Read more >
Email photo as attachment, not embedded, in iOS 14
I found a workaround that is working well for me. Instead of sending them to your email through the email app, send them...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found