My problem is not particularly VB.Net specific but having looked around this forum, I didn't know exactly where to post it and considering that I'm writing my program in VB.Net, I just decided to do so here. I apologize in advance, if that was wrong of me.
Part of my program is supposed to create a .eml file containing either an xml or a pdf file or both as attachments.
Prior to writing this program, I had never seen what a .eml file looks like, let alone an .eml file with attachments(I never used any of the outlooks), so I got someone to send me an email containing both these attachments and save the .eml file, so I could use this as a template in my own program. So far so good.
However, I noticed that the pdf file, after having been attached, is a huge string of letters(see below). Probably some sort of encoding. My problem is, my program is going to be creating several different pdf files and adding them as attachments to .eml files. How do I encode the different pdf files into a similar huge string of text as the one below? Or am I going about this the wrong way? What would be an alternative way to do this? Because having to encode that long string of text seems like it would be a very daunting task.
Long story short: How do I programatically create an .eml file that contains a .pdf as attachment?
Any help whatsoever would be very appreciated. Thanks.
Below is what the section containing the pdf attachment looks like in the .eml file when opened by a text editor:
thanks for your quick reply. I'm doing this at the request of my boss. From his explanation, the computer on which the pdf and xml files will be created have no connection to the internet, so the attachment should be stored in an .eml file to be somehow sent later. I don't know the details about how it's going to be sent later. All I know is that he wants the mail to be stored in .eml format. Does this help answer your question?
Yes, and I think that's the way .eml file works, try to look into scheme to know how to attach multiple files, but don't walk in string compression algorithms, it'd talk a lot of time without proper effect.
thanks for your suggestion. For now, I've been able to solve the problem of coding the pdf into pure text as was included in my first post.
Base64 is what's used to code the pdf into ASCII format for mail transfer and I found there is a method in .net called Convert.ToBase64String() that takes a string and converts it to base64. So I read the pdf to be used as an attachment into an array of bytes and passed this array of bytes as the argument of the Convert.ToBase64String() method. The method returns a string which I subsequently inserted at the appropriate position into my .eml template. I think that will suffice for my purpose
wow, that was almost 3 years ago... sorry I'm only getting to see the email notification sent by Daniweb now... it somehow landed in my spam box.
I wrote that code while I was working for a different company almost 3 years ago and I will have to look in my backups to see if I still have a copy. Unfortunately, I'm at work right now and the fastest I can get to that code is probably 24 hours from now, but when I do, I'll make sure to get back to this thread.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.