The Chilkat Email component makes it so you don’t need to concern yourself with how the internals of an email (i.e. the MIME) is formatted. Regardless of the encoding (base64, quoted-printable, etc) or charset(s) used in the MIME, the coding is the same. For example, this VB.NET code extracts an MS-WORD doc from an email. A method such as GetAttachmentData returns the bytes of the attachment regardless of how it was encoded in the MIME. The same applies to method or properties that return strings. For example, the email.Subject property always returns a Unicode string. It doesn’t matter if the email used a different charset, or if the string was "Q" or "B" encoded in the MIME…
Dim email As New Chilkat.Email()
email.LoadEml("test.eml")
' How many attachments?
If (email.NumAttachments < 1) Then
Exit Sub
End If
If (email.GetAttachmentFilename(0).EndsWith(".doc")) Then
Exit Sub
End If
' Get the 1st attachment (i.e. the attachment at index 0)
Dim msWordData As Byte()
msWordData = email.GetAttachmentData(0)
' Write the bytes to a file.
System.IO.File.WriteAllBytes("test.doc", msWordData)
' Do the same thing without first copying the attachment to a byte array:
email.SaveAllAttachments("c:/myAttachmentsDir")
' Save this specific attachment:
email.SaveAttachedFile(0, "c:/myAttachmentsDir")