Results 1 to 13 of 13

Thread: VB6 how to get media from code base64 text

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    22

    VB6 how to get media from code base64 text

    Hi there,

    I've a vb6 email program, it's enable to receive email by pop3 protocol.

    what I'd like to do is to decode all the coded base64 media embedded in email message.

    How can i do that ? ..it's very important for me ..I could buy a therd part software to get the result.

    Thank you all

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    Maybe this will give you something to play around with
    Attached Files Attached Files

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    or this one and maybe even better
    Attached Files Attached Files

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    22

    Re: VB6 how to get media from code base64 text

    I Tried "Base64Encoder.zip" but my vb6 says that i need :
    "Visual Basic 6 Virtual Machine Type Library 1.0 by Michel Rutten -
    Declarations and aliases for (undocumented) functions in the VB6 runtime library.
    " ..i just download it but it's just a VBVM6Lib.tlb file, what could i do? ( sorry i'm not so skilled )

    the second file "CryptoBase64.zip" seams that doesn't convert a code based64 string to an image (for example )

    I've got an html email in my inbox and if i see its html i see :
    <IMG =
    src=3D"cid:005e01c1c8c6$d0793a10$0100a8c0@mailenable.com"=20
    width=3D100>


    at the end of email i've got :

    Content-Type: image/gif;
    name="stamp_logo.gif"
    Content-Transfer-Encoding: base64
    Content-ID: <005e01c1c8c6$d0793a10$0100a8c0@mailenable.com>

    R0lGODlhvAA8ANUAAPHx8dDQ0KbM+drq/OPj48ff+/r6+pfD+LzZ+uzs7MHBwdXn/NnZ2fj7/8vL
    y6zP+fH3/rrX+vb29sbGxuPv/Z7H+NTU1Mjf+/D2/p/I+N7e3rXU+q7Q+eny/efn5+Hu/dPl/MTd
    +8Hb+6XL+erz/svh+9zr/fj7/rPT+urz/c7j/MDb+ri4uJC/9////wAAAAAAAAAAAAAAAAAAAAAA..........


    now I know that this is MailEnable Logo and i can see it by the html preview .. what i want to do is to save this embedded content in it's original content. : "stamp_logo.gif"

    can i do that whit that two files ?

    thank you!

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    The crypto works. It allows you to encode any file into Base64 amd it also allows you to take any already Base64 encoded file and convert it back to it's normal (decoded) state.

    The cryptp only gives you the code to encode/decode.

    You must extract out from the email the entire encoded image data (and the image data only) and save it as a seperate file. Now in a program load that file up and call the code that does the decoding in the crypto program. I know it works because I use it all the time and I use it exactly the same as I am saying to you what to do.

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: VB6 how to get media from code base64 text

    Google is your friend for stuff like this, here's one that is apparently fast:
    http://www.paradoxes.info/code/base64.html

    More results from that search:
    http://www.google.com/search?hl=en&q...=Google+Search

    And another site to check out that has a lot of base64 encoding/decoding code:
    http://www.pscode.com/vb

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    coullins,

    Here is a little sample project which uses code from that Crypto project just to show you that it does indeed work. Just download the zip, unzip it, and open up the project and run it. Then look in your working folder for the results.
    Attached Files Attached Files

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    22

    Re: VB6 how to get media from code base64 text

    Hi jmsrickland,
    encode-decode.zip it's fantastic! it's what i was looking for! greate!

    the strange thing is that if i copy&paste the base 64 code from mail email and try to decode it... it doesn't work!

    It's seams that the gif image sent in email is not coded in base 64 ( but it only seams) , couse i read exactly :

    Content-Type: image/gif;
    name="!cid_005e01c1c8c6$d0793a10$0100a8c0@mailenable.gif"
    Content-Transfer-Encoding: base64
    Content-ID: <001201c8c08a$49d1b880$df01a8c0@famgurupc>

    R0lGODlhvAA8ANUAAPHx8dDQ0KbM+drq/OPj48ff+/r6+pfD+LzZ+uzs7M....


    if i try to encode (mailenable.gif) trough the "encode-decode" vb program you give me, the encoded code is not the same i can read in my email!
    ..that's why it doesn't work!

    In my email, encoded code start like this :
    R0lGODlhvAA8ANUAAPHx8dDQ0KbM+drq/OPj48ff+/r6+pfD+LzZ+uzs7M....

    If i encode (mailenable.gif) with vb program it starts like this :
    RwBJAEYAOAA5AGEAvAAAADwAAADVAAAAAADxAPEA8QDQANAA0A....

    and they could be both base 64!

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    the strange thing is that if i copy&paste the base 64 code from mail email and try to decode it... it doesn't work

    The program does both. It takes a real image or picture (that's the one in the zip file) and decodes it into base 64. It also takes an already encoded base 64 and decodes it back to it's original state.

    If you extract out the base 64 data from your email (and you need to make sure you are getting all of the base64 data ) and save that data in a file then in the program change the Open to point to your file and load it into the decode part of the code it will work. That example shows you exactly how to make it.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    22

    Re: VB6 how to get media from code base64 text

    jmsrickland, i'm doing the same, but it doesn't work.

    This is all th code in my email, till the end of message :
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=3DContent-Type content=3D"text/html; =
    charset=3Diso-8859-1">
    <META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR>
    <STYLE></STYLE>
    </HEAD>
    <BODY bgColor=3D#ffffff>
    <DIV><FONT face=3DArial size=3D2><IMG alt=3D"" hspace=3D0=20
    src=3D"cid:001201c8c08a$49d1b880$df01a8c0@famgurupc" align=3Dbaseline=20
    border=3D0></FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Ciao</FONT></DIV></BODY></HTML>
    
    ------=_NextPart_001_0014_01C8C09B.0D5F4370--
    
    ------=_NextPart_000_0013_01C8C09B.0D5F4370
    Content-Type: image/gif;
    	name="!cid_005e01c1c8c6$d0793a10$0100a8c0@mailenable.gif"
    Content-Transfer-Encoding: base64
    Content-ID: <001201c8c08a$49d1b880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CoFNTMsjH3fIyZeRbHADAFwYuRfAQgpwYGds3wHf9zQkXEt4F2Se0KT4oDlJ7Agv
    FF8WN7nLDIhyCSc0ovcOmUrMvW9Ot4ranHYzAVNNywLoksAjmxakVDkgmqnCoybP8CQeclN6u7ya
    ILE0SjIKUz/zAw4jFTm+9zmSNwxIAAASoIFUJYBon0KeC5Cpgeok4FrXJIJ7pFmpfs4ToFAM59fA
    uceXKakIHQhNOU1pymHuJp2/WacqXYBAA8jPNxMolQceyRtppc9nl4OPuX6jAAJAcX9XAjoABySz
    ARLOJRfmu5QHMqYEAFzKgS9FQk4v9cAkCCg8fbkMFo6anKQqFUJMBYxTnxqfqCpmqlSVwkysCo+3
    ZFUMJ9gqV0fSla+a9axoTata18rWtQYBADs=
    
    ------=_NextPart_000_0013_01C8C09B.0D5F4370--

    the embedded image is the same one in attached.
    now if you try to encode the image i give you, you'll see that the generated base 64 code, is different from the one in mail message.
    or ..
    you can try by your self by sending that gif in your mailbox, take a look at the html and copy&paste the base code 64 of that image,.... it'll be different from the one you can generete with the vb program... and it will not work
    Attached Images Attached Images  

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    OK, I found the problem.

    The original zip I posted in #3, CryptotoBase64.zip works. You just didn't know how to use it so I made a simple cut-down version of it and posted it in #7, encode-decode.zip but when I did that I only put in one method of converting so here is what yo do.

    In the code of the little cut-down version make the following changes:
    Code:
    Private Sub cmdEncode_Click()
     Dim FileInputData As String
     
     Dim bytBuf() As Byte
        
     Dim s As String
        
     Open App.Path & "\BIG_GIF_IMAGE.gif" For Binary As #1
     FileInputData = String(LOF(1), 0)
     Get #1, 1, FileInputData
     Close #1
        
     '
     ' Comment out this line
     '
     'bytBuf = FileInputData
     
     '
     ' Add this line
     ' 
     bytBuf = StrConv(FileInputData, vbFromUnicode)
        
     s = CryptoBase64.Encode(bytBuf)
     
     Open App.Path & "\MyEncodedGifImage.txt" For Binary As #1
     Put #1, 1, s
     Close
     
     MsgBox "Finished Encoding"
    End Sub
    
    Private Sub cmdDecode_Click()
     Dim s As String
     Dim InputData As String
     
     Open App.Path & "\MyEncodedGifImage.txt" For Binary As #1
    
     InputData = String(LOF(1), 0)
     Get #1, 1, InputData
     Close #1
     
     '
     ' Comment out this line
     '
     's = CryptoBase64.Decode(InputData)
    
     '
     ' Add this line
     ' 
     a = StrConv(CryptoBase64.Decode(InputData), vbUnicode)
    
     Open App.Path & "\MyTestImage.gif" For Binary As #1
     Put #1, 1, s
     Close #1
     
     MsgBox "Finished Decoding"
    End Sub
    I believe you will find that this will do what you want.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    22

    Re: VB6 how to get media from code base64 text

    IT.....WORKS!!!! Thank YOU!!!!

    the only thing i change is the class

    ...just because it still didn't decode the image in mail!

    So i've changed the class in yor app whit the one that DigiRev has post [http://www.paradoxes.info/code/base64.html]

    and it WORKS!!

    thank you very very much for your help!!


  13. #13
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 how to get media from code base64 text

    ...just because it still didn't decode the image in mail!

    Well I tested it with that image and I got it to work just as is. Don't know why you had to make any changes but I'm glad you got it to work even if you had to change the class.

    BTW: that link in your last post is invalid


    BTE Again: I was just reading some of my notes about Crypto and it turns out that it is the method that is used internally by Internet Explorer and Outlook Express and all other MS components and applications that need to do Base64 conversions.
    Last edited by jmsrickland; May 28th, 2008 at 11:26 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width