|
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
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">
charset=3Dus-ascii">
Tinei Nyatsvimbo
|
|
|
|
|
Hi Tinei,
Try replacing the ParseBody function with this one:
Public Function ParseBody() As String
'To get the body, everything after the first null line of the message is it (rfc822)
Dim strTmp As String
Dim intLenToStart, intLenToend As Integer
'set the temp var to the message body by getting everything after the null line
strTmp = m_MessageSource.Substring(m_MessageSource.IndexOf(vbCrLf + vbCrLf))
'get the encoding of the message out, that way we know if we have to run it through the base64 decode
'routine or not
If InStr(m_MessageSource, "Content-Transfer-Encoding: base64") Then
'call the decode routine
strTmp = DecodeBase64(strTmp)
End If
'try and extract the plain text out of the email body
intLenToStart = InStr(strTmp, "Content-Type: text/plain")
strTmp = strTmp.Substring(intLenToStart, Len(strTmp) - intLenToStart)
'now find the first two new lines, this should be where the text starts
intLenToStart = InStr(strTmp, Chr(13) & Chr(10) & Chr(13) & Chr(10))
strTmp = strTmp.Substring(intLenToStart, Len(strTmp) - intLenToStart)
'find the end of the string, should be indicated by two more line ends and -------=_ Miuns another 2 places to get rid of
'the trailing 0D 0A
intLenToend = InStr(strTmp, Chr(13) & Chr(10) & Chr(13) & Chr(10) & "------=_") - 2
strTmp = strTmp.Substring(3, intLenToend)
'Strip out the odd hex that apears at the start and the end
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
|
|
|
|
|