473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Receive POP3 e-mails as .eml file

1
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,attachments 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.developerfusion.co.uk/show/2453/

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


Thanks,
Dan
Sep 25 '07 #1
1 17664
KRITGuy
6 Nibble
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_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData 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_Click()
' LogIn to the server ~ get settings from outlook express
Winsock1.Connect 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(Message$, " ")
Messages = Val(Mid$(Message$, x + 1, b - x))
Size = Val(Mid$(Message$, b + 1))

' MsgBox "Number of messages to download " & Messages

' Download all messages
For a = 1 To Messages

' Winsock1_DataArrival will save message as "Email-1.eml", "Email-2.eml" etc
Winsock1.Tag = "RETR"
Open "C:\Windows\Temp\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.SendData m$ + vbCrLf

received = False
Do Until received
DoEvents
Loop
End Sub
Oct 3 '23 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: siliconmike | last post by:
How to set up my PC (or what tools do I need) so that when any email comes to the server, a php script is automatically run to parse the email ? I've never done this before. Later I would like...
1
by: Lev Altshuler | last post by:
Hi, I am trying to count email messages in the mailbox and read their headers. In case that there are some messages on the POP3 server and they haven't yet got to the Inbox, I get a number of...
0
by: Eric McDaniel | last post by:
This may be a question for ActiveState support, but just in case anyone out there knows what the problem is... My call to Net::POP3->new() works fine when run through the perl interpreter, but...
12
by: Sven Groot | last post by:
I have a Windows Service application that acts as if it's an SMTP server. Outlook connects to this service, which is always running on the localhost. This works fine most of the time. However,...
1
by: _Doug Bell | last post by:
How do you receive email using .NET ?
4
by: Elise.D | last post by:
Hi, i have to migrate an old asp classic app into asp.net this application has a mail fonction -- Elise Dupont MVP .Net France
2
by: Ken Yu | last post by:
Hi, I want to make a program for receive E-mail by POP3, and forward to another E-mail Account, if the E-mail with Attachment , will delete the attachment before forward, where can i find more...
5
by: Al G | last post by:
Can someone point me in the right direction? I need to programmatically receive e-mails, and save the attachment, using VB2005. Al G
11
by: mp- | last post by:
I want to be able to allow people to check their email from my PHP online application. Given only the users 1) email address, 2) username (if applicable) and 3) password - how can I auto detect...
5
by: Craig Buchanan | last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want to ensure that each message is processed by only one client. In essence, I would like to treat a POP3 mailbox like a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.