Receive POP3 e-mails as .eml file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dansam
    New Member
    • May 2007
    • 1

    Receive POP3 e-mails as .eml file

    Hi everyone,
    My question is how to download emails from a pop server and save them as *.eml or *.mht files to localdisk as oultlook does ?
    Now what I know is that an .eml file can have images,attachme nts and all the e-mail formatting in it. So if I use a simple pop3 client to download message it will download the text part of the e-mail not full formatting - that's what I'm searching for!
    I found this link : http://www.example-code.com/delphi/download-pop3-email-to-eml.asp but the library is not free or open source , can you find something like this , my dear friends ?
    I also found another thing :http://www.developerfu sion.co.uk/show/2453/

    But It uses the winsock control which I can't found in VB.NET. Any one please help..


    Thanks,
    Dan
  • KRITGuy
    New Member
    • Jul 2023
    • 6

    #2
    This works fine to suck emails from your POP3 Account and export them as .eml files to C:\Windows\Temp

    It's a Winsock solution.

    I found it online, have used it and it works just fine. HOWEVER, I am looking for a simple VB6 example (in full) to convert the eml file attachments to files and export them too. So far, I have searched for about 14 hours solid. :-)

    I prefer vb6, but would accept a simple vb.net solution. Any help would be appreciated.

    Hope this helps.

    Converting it from vb6 to vb.net ought to be simple enough.

    Cheers,
    Kevin

    ' In general Declarations
    Dim received As Boolean
    Dim Message$
    Dim sckError


    Private Sub Winsock1_DataAr rival(ByVal bytesTotal As Long)
    Winsock1.GetDat a Message$

    Select Case Winsock1.Tag
    Case "RETR"
    Put #1, , Message$

    If InStr(Message$, vbLf + "." + vbCrLf) Then
    Close 1
    received = True
    End If

    Case Else
    sckError = (Left$(Message$ , 3) = "-ER")
    received = True
    End Select
    End Sub

    Private Sub Winsock1_Close( )
    Winsock1.Close
    End Sub

    Private Sub cmdCheckMail_Cl ick()
    ' LogIn to the server ~ get settings from outlook express
    Winsock1.Connec t txtHost, 110

    Do Until received: DoEvents: Loop

    If sckError Then MsgBox "An error occured trying to connect to server": Exit Sub

    sendMsg "USER " & txtUsername ' Send UserName
    If sckError Then MsgBox "Error with username": Exit Sub

    sendMsg "PASS " & txtPass ' Send Password
    If sckError Then MsgBox "Error with password": Exit Sub


    ' Get Number of Messages and total size in bytes
    sendMsg "STAT"
    x = InStr(Message$, " "): b = InStrRev(Messag e$, " ")
    Messages = Val(Mid$(Messag e$, x + 1, b - x))
    Size = Val(Mid$(Messag e$, b + 1))

    ' MsgBox "Number of messages to download " & Messages

    ' Download all messages
    For a = 1 To Messages

    ' Winsock1_DataAr rival will save message as "Email-1.eml", "Email-2.eml" etc
    Winsock1.Tag = "RETR"
    Open "C:\Windows\Tem p\eMail-" & a & ".eml" For Binary Access Write As #1

    sendMsg "RETR " & a
    List1.AddItem "eMail " & a & ": Downloaded"
    Next

    Winsock1.Tag = ""
    End Sub

    Sub sendMsg(m$)
    Winsock1.SendDa ta m$ + vbCrLf

    received = False
    Do Until received
    DoEvents
    Loop
    End Sub

    Comment

    Working...