OT: converted attachements

Discussion in 'Java' started by hilz, Mar 3, 2006.

  1. hilz

    hilz Guest

    Hi all...
    I have this question which is probably Off Topic, but maybe remotely
    related to Java. I hope someone might be able to help.
    Sometimes I receive emails with attachments that are converted to text
    and appear in the body of the message...( something similar to the text
    at the end of this message).
    Is there a way to convert this text into the actual binary file?
    if this is possible using a small Java program, i appreciate if someone
    would briefly explain to me what i need to do.
    Thanks


    Content-Type: image/jpeg; name="ATT00003.jpg"
    Content-Transfer-Encoding: base64
    Content-ID: <000d01c63ca6$b58dbac0$6401a8c0@port2>
    Content-Description: ATT00003.jpg
    Content-Location: 1_multipart%3F2_ATT00003.jpg

    /9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
    Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwh
    MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAAR
    CAFNAfQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
    AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
    FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
    h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
     
    hilz, Mar 3, 2006
    #1
    1. Advertising

  2. hilz wrote:
    > Content-Type: image/jpeg; name="ATT00003.jpg"
    > Content-Transfer-Encoding: base64
    >
    > /9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
    > Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwh
    > MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAAR
    > CAFNAfQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
    > AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
    > FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
    > h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl


    If you look at the two headers above they explain some stuff about your
    content. The encoding header states how the material is coded for safe
    transfer across a protocol (google "transfer encoding"), the type header
    says something about the actual type of the content after its transfer
    decoding has been performed. So you need to decode the base64 part, that
    should give you a binary string of the Content-Type format. So just
    google for a base64 lib.

    To really understand things like this have a look at the MIME rfc, which
    defined what such headers are and how to use/interpret them.

    /tom
     
    tom fredriksen, Mar 3, 2006
    #2
    1. Advertising

  3. hilz wrote:
    > I have this question which is probably Off Topic, but maybe remotely
    > related to Java. I hope someone might be able to help.
    > Sometimes I receive emails with attachments that are converted to text
    > and appear in the body of the message...( something similar to the text
    > at the end of this message).


    E-Mail MIME attachments are not physically attached in some way to an
    email. They are always part of the mail itself, and just logically
    treated as attachments.

    > Is there a way to convert this text into the actual binary file?
    > if this is possible using a small Java program, i appreciate if someone
    > would briefly explain to me what i need to do.

    [...]
    > Content-Type: image/jpeg; name="ATT00003.jpg"
    > Content-Transfer-Encoding: base64


    This says it is base64 encoded - which is the standard encoding used in
    MIME messages (uuencode would be another one). The JavaMail API can
    handle this. It provides the means to separate a MIME mail into the
    parts, and decode the parts into the original (binary) data.

    There are also (non-java) packages out there for handling such mails,
    e.g. the rather old metamail. However, every modern MUA should do this
    without the need to use any external tool. It has become absolutely
    standard to support MIME e-mails in mail clients since probably ten or
    15 years. The Thunderbird client which you use can of course do it
    without breaking a sweat.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Mar 3, 2006
    #3
  4. hilz

    Roedy Green Guest

    On Fri, 03 Mar 2006 03:04:07 -0500, hilz <> wrote, quoted or
    indirectly quoted someone who said :

    >Is there a way to convert this text into the actual binary file?


    that particular one is base64 encoded. You could use any of the base64
    decoder to get back the original bytes. See
    http://mindprod.com/jgloss/base64.html
    to understand the mechanism see
    http://mindprod.com/jgloss/mime.html
    and
    http://mindprod.com/jgloss/javamail.html

    One thing you might consider doing is upgrading to a more advanced
    mail reader that does not get confused.

    I am about to have a look at Thunderbird. I have been using Eudora
    for years but it does not properly support SMIME or PGP , and
    sometimes gets confused by attachments too. I would also like
    anti-spam properly integrated.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 3, 2006
    #4
  5. hilz

    hilz Guest

    Roedy Green wrote:

    > One thing you might consider doing is upgrading to a more advanced
    > mail reader that does not get confused.
    >
    > I am about to have a look at Thunderbird. I have been using Eudora
    > for years but it does not properly support SMIME or PGP , and
    > sometimes gets confused by attachments too. I would also like
    > anti-spam properly integrated.
    >



    Actually this does not happen in Thunderbird. I only use Thunderbird for
    news.
    The problem i run into is in emails i receive at my hotmail :( account,
    and i am viewing them using firefox (that is probably irrelevant).
    So i don't have control over anything pretty much.

    I am looking into writing a small utility to extract the attachement
    from the text. you guys have provided me with some good information. I
    just need to find the time to actually sit and write it!

    thanks
     
    hilz, Mar 3, 2006
    #5
  6. hilz

    hilz Guest

    Roedy Green wrote:
    > On Fri, 03 Mar 2006 03:04:07 -0500, hilz <> wrote, quoted or
    > indirectly quoted someone who said :
    >
    >> Is there a way to convert this text into the actual binary file?

    >
    > that particular one is base64 encoded. You could use any of the base64
    > decoder to get back the original bytes. See
    > http://mindprod.com/jgloss/base64.html
    > to understand the mechanism see
    > http://mindprod.com/jgloss/mime.html
    > and
    > http://mindprod.com/jgloss/javamail.html
    >
    > One thing you might consider doing is upgrading to a more advanced
    > mail reader that does not get confused.
    >
    > I am about to have a look at Thunderbird. I have been using Eudora
    > for years but it does not properly support SMIME or PGP , and
    > sometimes gets confused by attachments too. I would also like
    > anti-spam properly integrated.
    >


    Roedy,
    I read the bas64 page on your website, and it seems to explain the
    situation very well.
    One thing that came to mind is the end of line characters.
    If you notice, the characters are wraped at some specific length.
    I assume i will have to remove those end of line characters when i am
    processing the string in order to decode it. is that correct?
     
    hilz, Mar 3, 2006
    #6
  7. hilz

    Roedy Green Guest

    On Fri, 03 Mar 2006 15:31:01 -0500, hilz <> wrote, quoted or
    indirectly quoted someone who said :

    >The problem i run into is in emails i receive at my hotmail :( account,
    >and i am viewing them using firefox (that is probably irrelevant).
    >So i don't have control over anything pretty much.


    I don't know what hotmail does with attachments, but if you forwarded
    tem to a real email account perhaps they would come through unscathed.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 3, 2006
    #7
  8. hilz

    Roedy Green Guest

    On Fri, 03 Mar 2006 16:06:47 -0500, hilz <> wrote, quoted or
    indirectly quoted someone who said :

    >situation very well.
    >One thing that came to mind is the end of line characters.
    >If you notice, the characters are wraped at some specific length.
    >I assume i will have to remove those end of line characters when i am
    >processing the string in order to decode it. is that correct?

    no. They are just noise and are automatically ignored. Any
    character not in the base64 set is discarded. e.g. \n tab.

    My version of Base64 8 comes with well-commented source. It is not
    rocket science. That's why there are so many to choose from.

    http://mindprod.com/products1.html#BASE64

    Someday when I have a brain freeze I will run a bakeoff between them
    to see if any are noticeably better.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 3, 2006
    #8
  9. hilz

    hilz Guest

    Roedy Green wrote:
    > On Fri, 03 Mar 2006 15:31:01 -0500, hilz <> wrote, quoted or
    > indirectly quoted someone who said :
    >
    >> The problem i run into is in emails i receive at my hotmail :( account,
    >> and i am viewing them using firefox (that is probably irrelevant).
    >> So i don't have control over anything pretty much.

    >
    > I don't know what hotmail does with attachments, but if you forwarded
    > tem to a real email account perhaps they would come through unscathed.


    I tried that before, and didn't work
    seems they come to hotmail that way.
     
    hilz, Mar 4, 2006
    #9
  10. hilz <> burped up warm pablum in
    news:4I1Of.1994$3k1.983@dukeread03:

    > I am looking into writing a small utility to extract the attachement
    > from the text. you guys have provided me with some good information. I
    > just need to find the time to actually sit and write it!


    I realize it's a pain to change email addresses but have you considered
    changing to another email provider. eg. Yahoo lets you use pop3 to access
    your mail ($20/year) and they also pop up icons that can be clicked on to
    download attachments (free).
     
    Tris Orendorff, Mar 4, 2006
    #10
  11. hilz

    Roedy Green Guest

    On Sat, 04 Mar 2006 21:46:46 GMT, Tris Orendorff
    <> wrote, quoted or indirectly quoted someone
    who said :

    >I realize it's a pain to change email addresses but have you considered
    >changing to another email provider. eg. Yahoo lets you use pop3 to access
    >your mail ($20/year) and they also pop up icons that can be clicked on to
    >download attachments (free).


    Main webmail are Gmail, Hotmail, Yahoo, Aol, others?
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 5, 2006
    #11
  12. hilz

    hilz Guest

    Tris Orendorff wrote:
    > hilz <> burped up warm pablum in
    > news:4I1Of.1994$3k1.983@dukeread03:
    >
    >> I am looking into writing a small utility to extract the attachement
    >> from the text. you guys have provided me with some good information. I
    >> just need to find the time to actually sit and write it!

    >
    > I realize it's a pain to change email addresses but have you considered
    > changing to another email provider. eg. Yahoo lets you use pop3 to access
    > your mail ($20/year) and they also pop up icons that can be clicked on to
    > download attachments (free).
    >


    Actually I have Gmail too, and i think it is superior to all other free
    webmail services i've tried. But the point is that I just can't give up
    my hotmail account.
     
    hilz, Mar 5, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan
    Replies:
    4
    Views:
    294
    Curt_C [MVP]
    Dec 21, 2004
  2. =?Utf-8?B?TmVhbA==?=

    Attachements for SMTP mail

    =?Utf-8?B?TmVhbA==?=, Aug 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    433
    Stefan
    Aug 29, 2005
  3. Replies:
    2
    Views:
    505
  4. =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    MailMessage Trouble Sending Large Attachements

    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Sep 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    294
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=
    Sep 22, 2006
  5. srinivasan srinivas
    Replies:
    0
    Views:
    265
    srinivasan srinivas
    Dec 3, 2008
Loading...

Share This Page