Results 1 to 4 of 4

Thread: modify email function

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    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

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    Re: modify email function

    Thank you so much. That was very helpful.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: modify email function

    RFC1939 aka Post Office Protocol - Version 3
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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
  •  



Click Here to Expand Forum to Full Width