|
|
Comments and Discussions
|
|
 |

|
Plain and Simple. To the point. Easy to understand. Nice Job.
|
|
|
|

|
Luke,
Excellent work and I enjoy your blog.
For those of you who were looking for more, check out...
David Goben's Blog on Slideshare.net[^]
I haven't read it all but it looks interesting.
|
|
|
|

|
Good information. Thanks !
|
|
|
|

|
Hi,
wondering if you have this codes in C#. Could you attached it here?
It will be much appreciate if you have it..
|
|
|
|

|
i got an error
A connection attept failed because the connected party did not properly respond after a period of time, or established connection failed bcoz connected has failed to respond 173.194.79.108:110
plz hhelp me soon
|
|
|
|

|
I got this...
pop3 error unexpected response from mail server getting email body - err invalid command...
I don't know what to do..
Thanks
|
|
|
|

|
I had the same error and was able to fix it by calling the RETR command directly instead of using the SendData function. Replace the GetMailMessage function with this:
Public Function GetMailMessage(ByVal intNum As Integer) As String
Dim strTemp As String
Dim strEmailMess As String = ""
Try
Dim strRetr As String = "RETR " & intNum
Dim outBuff As Byte()
outBuff = ConvertStringToByteArray(strRetr & vbCrLf)
POP3Stream.Write(outBuff, 0, strRetr.Length + 2)
If WaitFor("+OK") = False Then
POPErrors("Unexpected Response from mail server getting email body" & vbNewLine & strDataIn)
GetMailMessage = ("No Email was Retrived")
Exit Function
End If
strTemp = inStream.ReadLine
While (strTemp <> ".")
strEmailMess = strEmailMess & strTemp & vbCrLf
strTemp = inStream.ReadLine
End While
GetMailMessage = strEmailMess
Catch ex As Exception
GetMailMessage = "No Email was Retrived"
End Try
End Function
|
|
|
|

|
Can somebody tell me what I must do if I want to get mail from the hotmail server. I already set the port to 995, but when I try to connect it says:
Unable to read data from the transport connection: [here comes a translated message, my os is dutch] The external host disconnected.
How do I get this working??? Or are the mails encrypted, so the program just can't read it?
Thanks!
Steef
|
|
|
|

|
Hi,
If you look at http://lifehacker.com/5169684/hotmail-finally-enables-pop3-worldwide[^] you can see connecting to hotmail over pop3 requires an ssl connection, something this example does not support.
As quite a few people have asked for this if i get time over the next couple of weeks i might see whats involved to update this article to include ssl support
|
|
|
|

|
Hello Luke,
I'm interested in your code so I was reviewing but then I ran into one issue and will appreciate it if you give me some help on it. Most of the time I get an error as "A Problem occurred while decoding a base64 email".
Any solution to this problem?
Thanks!
Thanks for reading my aticle
|
|
|
|

|
Hi Ramsin,
Its probably hitting an attachment, i would imagine that what's causing the error
Cheers
Luke
|
|
|
|

|
Hi,
Have u fix the problem that occurs decoding base 64 email?
I got that error, when an email has attachment(s). And this is the error:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.
Anyway, can you let me know how to retrieve attachment(s) using that code.
Thank you.
|
|
|
|

|
Quite a few people have asked if this demo supports pop3 over ssl, in its current state the answer to this question is no, so if you are trying to download of gmail or anything over port 995 (the normal secure pop3 port) its not going to work.
I've had a quick look around and found an open project at http://www.mentalis.org/soft/projects/ssocket/
Look like it should be possible to mod this demo (or create a new one) using this library to add ssl support. If anyone does it let me know and ill post a link here to it, or when i get round to it i'll have a go
|
|
|
|

|
When the content of email is not English but the Chinese, it prompt the following error:
A problem occured while decoding a base64 email.
Do you have any idea to fix this issue? Thanks in advanced.
Yueming Wu
|
|
|
|

|
Hi,
Its probably having trouble with the character set. If you forward me the email i will take a look
|
|
|
|

|
Thanks for your reply,
I checked it more after I asked that question. It does not the trouble with the character set. The error occuried when there is a picture embeded in the email. I believe you are finding the way to fix this now. If you still want me to send you that email, please let us know. The problem is that I can not find your email address.
Thanks again for your help.
Yueming Wu
|
|
|
|

|
forward me the email to luke@beakersoft.wanadoo.co.uk and ill have a look
|
|
|
|

|
Hi,
Have u fix the problem that occurs decoding base 64 email?
I got that error, when an email has attachment(s). And this is the error:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.
Anyway, can you let me know how to retrieve attachment(s) using that code.
Thank you.
|
|
|
|

|
Someone uses this with gmail?
|
|
|
|
|

|
hi,
i cant access pop.gmail.com ...
in this link, they say that the port is 995
http://mail.google.com/support/bin/answer.py?answer=13287[^]
i changed your program in line 24
to connect to port 995
TCP.Connect(strServer, 995)
and the application show me an error message...
POP3ERROR -
Unexpected response from mail server when connecting...
thanks
|
|
|
|

|
i think the data is probably coming back encrypted, and as it stands this demo wont deal with that (it would explain why your getting an unknown response). I have a look this week and try and confirm what is happening.
|
|
|
|

|
I've been using this super app for awhile, but I think it does not work with SSL. Can you confirm? Any other alternatives?
Thanks
|
|
|
|
|

|
As mentioned in a previous message, adding support for attachments is very difficult. Is anyone is willing to help me write/debug it we can give it a go, i dont have enough time to tackle this on my own at present
|
|
|
|

|
How do i get rid of this part:
This is a multi-part message in MIME format.
--_bff0947c-7186-4598-9d02-f9df9c7b0372_
Content-Type: text/plain;charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
since it makes retrieving the data out difficult.
Tinei Nyatsvimbo
|
|
|
|

|
Hi,
At what point are you seeing that string, is it at the start of the email body?
|
|
|
|

|
Hi Luke,
The text is coming out at the beginning of the message and there is also some at the end of the message. I noticed now that it is as a result of the message being send as HTML from public domains like gmail which seem to add on that text. My problem with that is my data contained in the email will have excess details that i don't want to import into the database. Can this be stripped out?
Cheers & Thanks,
Tinei
Tinei Nyatsvimbo
|
|
|
|

|
You will be able to strip it out, its just a case of working out where the string starts and ends. If you forward me a couple of example emails ill have a look to see what the rfc's say about it, and try and come up with something
|
|
|
|

|
This is a multi-part message in MIME format.
------=_NextPart_000_0004_01C8FEDD.61546ED0
Content-Type: text/plain;charset="us-ascii"
Content-Transfer-Encoding: 7bit
'KSN001', '0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008
17:02:43#, 'BAG', 'WYVERNE', '', False , 'KSN00102D', 1 , '0006', 'COPPER
CONCENTRATE', '', '2510006', 'KSN00102D', 1198.4 , , '', '', '', '', '', '',
'', '', '', '', ' 'KSN001', '0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG',
#09/Aug/2008 17:03:10#, 'BAG', 'WYVERNE', '', False , 'KSN00102C', 1 ,
'0007', 'COPPER CONCENTRATE', '', '2510007', 'KSN00102C', 1198.4 , , '', '',
'', '', '', '', '', '', '', '', ' 'KSN001', '0', '', '', 0 , 0 , '', '', '',
'', 0 , 'BAG', #09/Aug/2008 17:03:39#, 'BAG', 'WYVERNE', '', False ,
'KSN00102B', 1 , '0008', 'COPPER CONCENTRATE', '', '2510008', 'KSN00102B',
1198.4 , , '', '', '', '', '', '', '', '', '', '', ' 'KSN001', '0', '', '',
0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008 17:03:58#, 'BAG', 'WYVERNE',
'', False , 'KSN00102A', 1 , '0009', 'COPPER CONCENTRATE', '', '2510009',
'KSN00102A', 1198.4 , , '', '', '', '', '', '', '', '', '', '', ' 'KSN001',
'0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008 17:04:17#,
'BAG', 'WYVERNE', '', False , 'KSN001029', 1 , '0010', 'COPPER CONCENTRATE',
'', '2510010', 'KSN001029', 1198.4 , , '', '', '', '', '', '', '', '', '',
'', ' 'KSN001', '0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008
17:06:10#, 'BAG', 'WYVERNE', '', False , 'KSN001028', 1 , '0011', 'COPPER
CONCENTRATE', '', '2510011', 'KSN001028', 1198.4 , , '', '', '', '', '', '',
'', '', '', '', ' 'KSN001', '0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG',
#09/Aug/2008 17:06:28#, 'BAG', 'WYVERNE', '', False , 'KSN001027', 1 ,
'0012', 'COPPER CONCENTRATE', '', '2510012', 'KSN001027', 1198.4 , , '', '',
'', '', '', '', '', '', '', '', ' 'KSN001', '0', '', '', 0 , 0 , '', '', '',
'', 0 , 'BAG', #09/Aug/2008 17:06:44#, 'BAG', 'WYVERNE', '', False ,
'KSN001026', 1 , '0013', 'COPPER CONCENTRATE', '', '2510013', 'KSN001026',
1198.4 , , '', '', '', '', '', '', '', '', '', '', ' 'KSN001', '0', '', '',
0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008 17:07:06#, 'BAG', 'WYVERNE',
'', False , 'KSN001025', 1 , '0014', 'COPPER CONCENTRATE', '', '2510014',
'KSN001025', 1198.4 , , '', '', '', '', '', '', '', '', '', '', ' 'KSN001',
'0', '', '', 0 , 0 , '', '', '', '', 0 , 'BAG', #09/Aug/2008 17:07:26#,
'BAG', 'WYVERNE', '', False , 'KSN001024', 1 , '0015', 'COPPER CONCENTRATE',
'', '2510015', 'KSN001024', 1198.4 , , '', '', '', '', '', '', '', '', '',
'', '
------=_NextPart_000_0004_01C8FEDD.61546ED0
Content-Type: text/html;charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v="3D"urn:schemas-microsoft-com:vml"" mode="hold" />xmlns =3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="3DContent-Type" content="3D"text/html;" mode="hold" />charset=3Dus-ascii">
<meta name="3DGenerator" content="3D"Microsoft" word="" 11="" hold=" /><style><br mode=" times="" new="" roman=";}<br mode=" edit=" spidmax=3D" 1026=" /><br mode=" 1=" /><br mode=">Tinei Nyatsvimbo </meta></head>
|
|
|
|

|
Hi Tinei,
Try replacing the ParseBody function with this one:
Public Function ParseBody() As String
Dim strTmp As String
Dim intLenToStart, intLenToend As Integer
strTmp = m_MessageSource.Substring(m_MessageSource.IndexOf(vbCrLf + vbCrLf))
If InStr(m_MessageSource, "Content-Transfer-Encoding: base64") Then
strTmp = DecodeBase64(strTmp)
End If
intLenToStart = InStr(strTmp, "Content-Type: text/plain")
strTmp = strTmp.Substring(intLenToStart, Len(strTmp) - intLenToStart)
intLenToStart = InStr(strTmp, Chr(13) & Chr(10) & Chr(13) & Chr(10))
strTmp = strTmp.Substring(intLenToStart, Len(strTmp) - intLenToStart)
intLenToend = InStr(strTmp, Chr(13) & Chr(10) & Chr(13) & Chr(10) & "------=_") - 2
strTmp = strTmp.Substring(3, intLenToend)
strTmp = Replace(strTmp, Chr(10) & Chr(9), "")
strTmp = Replace(strTmp, Chr(13), "")
ParseBody = Trim(strTmp)
End Function
I think it should do what you want, but i'm not sure if it will cope with emails that dont contain a html part.
Let me know how you get one
|
|
|
|

|
Will try it out and let you know.
Cheers,
Tinei
Tinei Nyatsvimbo
|
|
|
|
|

|
i decided to trim the message in the database. haven't had time to test your solution. will do so this week and let you know.
Thanks a lot
Tinei Nyatsvimbo
|
|
|
|

|
Hi Luke,
I know this is a very old thread but I just wanted to let you know that your solution is working wonderfully for me and the updated code for parsing the body is perfect.
Thankyou so much.
Hope all is well.
Cheers,
Fletch
|
|
|
|

|
i cannot retrieve the body of the message and also if i have an email from gmail received the to cannot be extracted as gmail uses to: with lowercase and outlook express uses To: with uppercase. if i convert them all to lower or upper it extracts the (to:from to:.plz help
|
|
|
|

|
hi,
What problem are you getting trying to extract the message body, are you getting any errors in the code or is it just not outputting anything?
As for the extracting of the too section of the mail, i dont think case matters (i've not got the code handy so i cant check) but i think it converts it to upper case somewhere in the code. The only reason i can think so that not working is the too is in a strange format or place, but I would'nt expect it.
Feel free to forward me an example email and ill have a look if you want
Cheers
Luke
|
|
|
|

|
i am getting following error messages continously
"POP3ERROR-Unexpected Response From Mail server When Connecting"
"POP3ERROR-Unexpected Response From Mail server When Sending User"
"Unable to write data to transport connection An Established Connection was Aborted by the software in your host machine"
"Unexpected error when getting number of emails:Unable to write data to transport connection An Established Connection was Aborted by the software in your host machine"
"Unable to write data to transport connection An Established Connection was Aborted by the software in your host machine"
can you please tell how to overcome this exception,which software is aborting the established connection.
waiting for reply
regards
Oersla Afroze Ahmed
|
|
|
|

|
Hi,
Without knowing you exact setup its hard to say exactly what's wrong but it sounds like a connectivity problem.
The best way to fault find things like this is to connect to the pop3 server on a command line and issue it some commands to make sure every thing's working.
At a command line (or using a client like putty) telnet to you mail server on port 110 i.e.
telnet mailserver.domain.com 110
When you do that you should get a line back telling you something like the version etc. If you get this far you can then try and login, retrieve message etc using the pop3 command set. Just search Google for them.
|
|
|
|

|
Hi Luke,
Great article! Thanks.
Have you done any work on attachments?
If so, would you like debugging help?
Randy (Mycroft.xxx)
|
|
|
|

|
Hi Randy,
I have looked tentatively at adding support for attachments, but it's not at all straight forwarded!
We would have to build into the app support for MIME types. (http://en.wikipedia.org/wiki/MIME) and that would not be all that easy. I would like to look into it more if people were interested, but it would be a lot of work. I don't mind starting the project off if you would be willing to do some of the work as well.
let me know what you think
cheers
luke
|
|
|
|

|
Hi,
Wondering can you answer these two questions for me.Thanks a lot ~~
1) About the function "Delete Mail after Downloading",
I didnt tick the concerning function while loading the program
but still can delete mails from the mail server.
Is there any ways to Download mail into the program, and let the mails remains in the mail server?
2) When receiving mails in the chinese characters,
the program will show "A problem occured while decoding a base64 email"
Can u teach me what codes I have to write to see chinese characters.
Please help me~~ tq
Best regards,
Edmond
|
|
|
|

|
Hi,
I'll try and answer your questions in here and not my blog as more people will probably see it!
1) In the form code I have purposely left the part that would delete the mail of the server commented out so if you just run the code it wont delete any mail of the server. To delete any mail you will have to tick the box on the form AND uncomment the popConn.MarkForDelete(i) line.
Also note that the mail is only marked for deletion at this point, it is actually deleted when you issue the QUIT command to the server, this is done by the popConn.CloseConn line right at the end.
When the program runs and gets mail of your server, it puts the entire content of the message into the strMailContent variable. This includes all the headers, mime types, too/from headers etc. The function called ParseBody then tries to extract only the body text out of the email, and stores it in the strBody variable. If you uncomment out the message box just after where the message gets added to the list you will see all the sections of the email.
2)This could prove tricky! The part of my class that attempts to get the body text out isn't brilliant, but at the time i was only dealing with simple messages. I dont really know that much about how you will get the Chinese chars out of the email within vb.net. You will probably have to do something clever regarding what character set you read the email as. You can send me an example email if you like and I can have a look but its not something I have ever dealt with before.
|
|
|
|

|
:-DEven if this does sprout some errors at me, finding it saved me hours of work. The hard part was the right query in MSDN and I laughed many times over at this line in your article:
Background
When i started to work with the .Net framework, one of the first things I noticed was its lack of support for downloading emails from a mail server. There is very good support for sending mail via the SMTP protocol, but nothing for receiving. The class came about when I needed a way of retrieving log files that were sent as emails, and acting on the information contained in the mail.
You can say that again! There sure is no support in VB.Net for downloading emails. I tried walkthroughs, I tried this, I tried that as queries and finally, checked a document when I wanted to do this back in January. I made notes about what I wanted to do then and realized in these notes ... existed the query I should be using! LOL -- got your code as one of the first tries. Then when I read about no support as you wrote it, I wasn't too surprised I had such a difficult time.
Thanks. If it needs any tweaking to work, I'll pass along my input.
Best,
Mike
Michael Durthaler
VB.Net Development/Maintenance
Musician, Cincinnati Area (Will play for food  )
mdurthaler@sbcglobal.net
|
|
|
|

|
Hi Mike,
Thanks for the feedback, I know some of the code's not perfect but it got me out of a hole! The support for mail protocols (apart from SMTP) in .NET terrible, i cant believe its all the way up to version 3 of the framework and still not even simple pop3 support.
Only good thing about it was I learnt something new!
If you make any mods to it ill post them up here and credit you.
Cheers
Luke
|
|
|
|

|
Thanks for the reply. I made the rookie mistake of sending you one via Outlook instead of here.
I'll fly by you our final use of the code once we're done. So far, it holds it's own with a few modifications but we don't have it integrated with the rest our application yet -- we're still writing it. I don't see any problems as it works well in and of itself.
Best,
Mike
Michael Durthaler
VB.Net Development/Maintenance
Musician, Cincinnati Area (Will play for food  )
mdurthaler@sbcglobal.net
|
|
|
|

|
Suppose i want to use this POP3 codings in localhost means how can i create the username account and password
|
|
|
|

|
I'm not really sure what you mean, if you want to run a pop3 server on your machine you'll have to use Windows2003 server as that has a built in service, or Linux offering
Cheers
Luke
|
|
|
|

|
I am new to Dot net technology. Can you please help in implementing this code. when I run this code it give me the following error
"Unable to read data from the transport connection. An existing connection was forcibly closed by the remote host"
Thnx.
|
|
|
|

|
Hi,
sounds like you aren't allowed to connect to the pop3 server you are trying to get at. Try connecting on telnet to the server on port 110 (the default pop3 port). If you can on let me know an post what line its giving you the error on and ill have a look.
Cheers
Luke
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A simple POP3 class to download emails from a mail server.
| Type | Article |
| Licence | CPOL |
| First Posted | 13 Mar 2007 |
| Views | 101,720 |
| Downloads | 6,150 |
| Bookmarked | 74 times |
|
|