|
-
Mar 26th, 2013, 10:57 AM
#1
Thread Starter
Addicted Member
modify email function
The below function retrieves a pop3 email message once the server is connected. I'd like to modify this function so that it doesn't download any email attachments. I'm trying to write some code to just view the email subject and the from email. Big attachments can slow down the execution of the program.
*******************
Function GetMessage(ByVal msgindex As Integer) As String
Dim tmpString As String
Dim Data As String
Dim SzData() As Byte
Dim msg As String
Try
Data = "RETR " & msgindex.ToString & vbCrLf
SzData = System.Text.Encoding.UTF8.GetBytes(Data.ToCharArray())
NetStrm.Write(SzData, 0, SzData.Length)
tmpString = RdStrm.ReadLine()
If tmpString.Substring(0, 4) <> "-ERR" Then
While (tmpString <> ".")
msg = msg & tmpString & vbCrLf
tmpString = RdStrm.ReadLine
End While
End If
Catch exc As InvalidOperationException
MsgBox("Message Retrival Failed: " & vbCrLf & Err.ToString())
End Try
Return msg
End Function
-
Mar 26th, 2013, 11:09 AM
#2
Re: modify email function
I think all you need to do is change the RETR command... as that's what is RETRieving the email... I don't remember if it's a different command (for some reason I want to say it's a GET, but I'm not sure) or if it's an option onthe RETR... but there is a way to get just the header info.
I'll see if I can find it.
-tg
edit - ah... here it is... http://www.electrictoolbox.com/artic...pop3-commands/ scroll down to the TOP command... TOP x 0 is the command, where x is the message number to retrieve... caveat is that not all POP servers support it though.... but the article is from 2004, so things may have changed...
-tg
-
Mar 26th, 2013, 12:17 PM
#3
Thread Starter
Addicted Member
Re: modify email function
Thank you so much. That was very helpful.
-
Mar 26th, 2013, 12:29 PM
#4
Re: modify email function
RFC1939 aka Post Office Protocol - Version 3
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|