This Class Library includes an SMTP class that supports the sending of
simple emails, or very complex emails that feature alternate views, such as Rich
Text or HTML, attachments with customizable encoding, optional ports, SSL
support, and many other features.
It also features a full-featured and fully-developed POP3 class that will
allow you to easily receive email from a POP3 server.
It also includes a fully packed Utilities class. This includes a utility
that will allow you to easily break an email down into its component parts.
Other utilities allow you to easily decode quoted-pritable, base64-encoded, and
Hex-encoded files. Another utility allows you to encode an 8-bit file into a
7-bit file with hex-tags. Still another utility will allow you to acquires a
plain text version of HTML data. All this, and so very much more.
The included 58-page PDF manual explains every detail of each class
and utility, how email is structured, how base64 and hex-tag encoding works, and
makes sending and receiving email within a custom processor easy and fast.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
Re-scan downloaded files using your personal virus checker before using it.
NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
If you don't have a virus scanner, you can get one at many places on the net
Terms of Agreement:
By using this code, you agree to the following terms...
You may use
this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this code from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
Thanks. I'm an information hog, but I like to share it with as many people as possible (hence, my huge free ebooks). This portion of my books started out in just trying to understand why .NET did not support a POP3 interface, and also why everyone thought it was nigh impossible to do under VB.NET, when all it was is a simple TCP interface, which I had been writing code for since the 80s in my mid-20s. Now I'm 56, but still an excited kid when it comes to learning new things. By sharing as much information as I can, the younger folks can use that to create even greater things that I have yet to imagine. We all win. (If this comment was disrespectful, please report it.)
Actually, the documentation contains examples of implementation. The code is so short and simple that I did not bother with an app. There are so many different directions one can goi with this that I thought it best to leave that to the user. Normally, people simply want to add email reading to a business app, or to make email access easier for Great Aunt Tesse. The interface is easy enough, but the tools to read email were missing, which I have provided. (If this comment was disrespectful, please report it.)
For those of you who have been asking me about HotMail: You may be having a problem if you are using the HTML version of HotMail, because that does not use POP3 I/O. However, Microsoft has finally enabled POP3 email access for all users of their Hotmail email service, according to http://www.ghacks.net/2009/03/14/hotmail-pop3-configuration/
Here is the information that have to be entered into the desktop email software so that Hotmail can be accessed (note that this is set up just like GMail):
* Incoming Server: pop3.live.com
* Incoming Port: 995
* SSL Encryption: yes
* Outgoing Server: smtp.live.com
* Outgoing port: 25 (use port 587 if the default port is not working)
* Authentication: yes
* TLS Or SSL: yes
(If this comment was disrespectful, please report it.)
The code has some problems reading the Content body for messages sent from gmail or yahoo. One fix would be, in the GetEmailInfo to change the code: Else ContentTypeData = sbAry(1) 'AlternateView, so stuff display character set 'Changes 'added those two lines for web based email messages (gmail, yahoo...) SeekingEncoding = False 'turn off seeking flag BuildingDataBlock = True 'turn on building data block flag Idx += 1 End If Case "content-transfer-encoding:" ... (If this comment was disrespectful, please report it.)
The library doesn't isolate correctly the content body for emails sent from gmail or yahoo mail. One quick fix would be to change the GetEmailInfo: Else ContentTypeData = sbAry(1) 'AlternateView, so stuff display character set 'Changes 'added those two lines for web based email messages (gmail, yahoo...) SeekingEncoding = False 'turn off seeking flag BuildingDataBlock = True 'turn on building data block flag Idx += 1 End If '=================================================== Case "content-transfer-encoding:" (If this comment was disrespectful, please report it.)
Good idea, though I use Gmail all the time, and have never needed to do this. However, that does not mean that someone else would not need your solution to get web-based mail. Thanks for the feedback. (If this comment was disrespectful, please report it.)
Hello, Thanks very much for these vb.net email classes. I am having problems i hope someone could help me with. I am implementing the pop3 class using a gmail account. I have one email message with 2 image attachments and 3 lines of contents. in my test code, i am calling: x = Utilities.GetEmailInfo(msg.Message). all header info are populated, but the x.MessageBody and x.Attachments are not populated. they return empty while subject, date, from, to, all ok. the GetEmailInfo is not invoking the boundaries section and splitting the message content. Ant help is appreciated. Thanks in advance (If this comment was disrespectful, please report it.)
Hello Again, I did debug the code regarding the getemailinfo not populating the bodytext and attachments. It looks like BuildingDataBlock set to false as a default and i "content-transfer-encoding:" and not being turned back on so the boundary count are never populated. I set BuildingDataBlock always to true, now I get bodycontent as well as attachements, but not properly parsed. the attachement has: Content-Disposition: attachment; filename="black_swan2.JPG" at start, so I cannot decode64tobyte, gets an error. So, what is the proper wat to get this working? Thanks very much. Georges. (If this comment was disrespectful, please report it.)
Thanks for posting this great library. It saved my project! I made some changes to the library in the GetEmailInfo function so that it works with more variations in email formats from different devices. The above fixes breaks emails in base64. So that if you check for base64 emails that aren't can be reported as such. I also had issues with email sent from iPhone's. So I made all the fixes and will post them tonight. I have to finish up one last thing for iPhones since the iPhone fix is outside the library I want to bring in as part of the library. Thanks again. (If this comment was disrespectful, please report it.)
I finally got this working for email sent from an iPhone. Another place that Apple has to do something different. So the issues is their email client doesn't use boundaries and the To field is after the content type. So the why GetEmailInfo parses the message it breaks it. I got it working but not in the cleanest way. I think that function should be rewritten with either multiple passes or not rely on certain order of fields and just grab then instead of looking for just header info and then content type and body. I might think about doing that but for now my workaround works. I can post the code later on. (If this comment was disrespectful, please report it.)
11/16/2012 7:12:41 AM:
Excellent! However, I cannot seem to get any attachments. I 've followed the examples in the pdf but i cannot get them, they show 0 in getmailinfo. I'm using gmail pop3. Could somebody please assist me with this? Thank you (If this comment was disrespectful, please report it.)
David, thanks so much for your code. It was incredibly useful, well written and excellently documented and commented - and also educational to read.
My specific project will be receiving emails with large PDF attachments and I was having significant performance issues with Utilities.GetEmailInfo(). I fixed it by replacing the ContentBody string with a StringBuilder (that I initialized to 8MB in size). That took execution of that routine from over a minute down to about 2 or 3 seconds.
Also, because of my specific application, I set the POP3.Response() routine's default buffer size to 16k (instead of ReDim ServerBufr(255)) - when fetching an email with a large attachment the "tail end" of the file will be large.
Thanks again for your code. I'm still in the early stages of using it. (If this comment was disrespectful, please report it.)
I'm having a bit of a problem. I am attempting to create a program that does periodical scans of a hotmail account, which uses POP3 SSL. The issues occur when after the function "Connect()" is executed. If I try to use the function "CheckResponse()", I get the following error: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." on line 140 of the POP3 class.
When I use the function "Connect()" then a following "Disconnect()", then finally another "Connect()", I get the following error: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." on line 52 of the POP3 class.
I have ensured that all inputs are correct, and have tested this with two hotmail accounts and one gmail account.
Any help regarding these problems would be greatly appreciated :). (If this comment was disrespectful, please report it.)
Hi, I am impressed with your code! I do have a question, is there a way to get the UUID from the email message? I want to compare that against what is already downloaded to make sure it is not downloaded twice.
Thank you for the post!
(If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular code, please
click here instead.)