Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7569073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:04:52+00:00 2026-05-30T15:04:52+00:00

I can read attachments sent from all email clients I’ve tested except for androids

  • 0

I can read attachments sent from all email clients I’ve tested except for androids default email app. It works through the gmail app in android though.

Here’s some of the code:

import email as emaillib

result, data = imap_conn.uid('fetch', email_id, '(RFC822)')
raw_email = data[0][1]

get_attachments(emaillib.message_from_string(raw_email))

def get_attachments(email_message_instance):
    attachments = []
    for part in email_message_instance.walk():
        if part.get_content_maintype() == 'multipart':
            continue
        if part.get('Content-Disposition') is None:
            continue

        data = part.get_payload(decode=True)
        if not data:
            continue
        filename = part.get_filename()

        print 'appending attachment with filename: ', filename
        attachments.append((filename, data))

    return attachments

When I send one attachment from the default email app in android it prints:

appending attachment with filename: None
appending attachment with filename: None
appending attachment with filename: =?utf-8?B?SU1BRzAxOTMuanBn?=

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:04:54+00:00Added an answer on May 30, 2026 at 3:04 pm

    Ok I solved the problem, It seems my android default mail app writes content disposition for everything.

    And the file name was all wicked as well.

    So I solved the problem with (Since I’m only interested in media attachments):

    from email.header import decode_header
        def get_attachments(email_message_instance):
            attachments = []
            for part in email_message_instance.walk():
    
                if part.get_content_maintype() not in ['image', 'video', 'audio']:
                    continue
    
                if part.get('Content-Disposition') is None:
                    continue
    
                data = part.get_payload(decode=True)
                if not data:
                    continue
    
                filename = part.get_filename()      
                filename =  u' '.join(w.decode(e or 'ascii') for w,e in decode_header(filename))        
                attachments.append((filename, data))
    
            return attachments
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write an application that can read email and attachments from a
How can I browse the email and download all attachments ? public string Connect_Email
How you can read a file (text or binary) from a batch file? There
I'd like to save an email, along with attachments, from Gmail (Google Apps) to
I want to add to my app a thin email client where you can
Can I read the mail and download the attachments using that imaplibrary in VB.Net
I have been able to read emails, and I can see the attachments, but
I want to know how can I read attachment messages without using scriplets in
Anyone can read the GoF book to learn what design patterns are and how
I can read the MySQL documentation and it's pretty clear. But, how does one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.