views:

16

answers:

3

Wondering if there's a way I can avoid fetching the attachments as well.

A: 

Yes, it returns the entire email source. The attachments are encoded as email parts.

You can use the Ruby Mail library to extracts all the attachments.

Simone Carletti
A: 
    I don't know about ruby , but it can be done only fetching Email Header.
    I am Fetching Email header in Python like below:

    resp, data = obj.uid('FETCH' , ','.join(map(str,uid_lst)),'(RFC822.HEADER RFC822.SIZE)')

    where uid_lst is the list of uids of emails which you want to fetch.

   Note: Email which has value of header field Content-Type = 'Multipart-Mixed' has an attachment. 
Avadhesh
A: 

Hi,

If all you want to do, is download the email body(ies), there isn't a clean way of doing this (at least none that I disovered).

What I had to do, was first download the headers and the body structures. Once I had the headers, I could determine what type of email it was (multi-part, alternative, or just a single bodied email).

Once I knew the structure, I could download the plain text or html body part as a body section.

Does that help?
--Dave

dave wanta