Article Overview
- Background
- Pre-requisites
- How to perform email parsing
- Connect with Server
- Authenticate to Server
- Go through all email
- Get email content
- Process email content
- Whole example together
- References, Page load, Model, Table
- Get all emails and set in table
- Get email content
- Set email content in table
- Output
- Summary
Background
There was a requirement where I had to read emails from an email box, and after that I had to process each email to generate a record into the database. There are various libraries using which you can perform email parsing.
OpenPop.NET is a robust open source POP3 client and MIME parser written
in C#. Here, I am putting all the key details at one place with entire examples.
Prerequisites
You MUST have basic knowledge of C#, ASP .NET, and Email Parsing.
Download “OpenPop.dll” from OpenPop.NET.
How to perform email parsing
There are mainly five steps to perform email parsing:
- Connect with Server
- Authenticate to Server
- Go through all email
- Get email content
- Process email content
Now, let us see in detail.
Connect with Server
You need host (server) name, port number, etc. details to connect with the POP3 email server.
objPOP3Client.Connect(host, port, useSsl);
Authenticate to Server
Once the server is connected you have to authenticate it using email (username) and password. This is your email box login details.
objPOP3Client.Authenticate(user, password);
Go through all email
After successful authentication you have to loop through each email one by one.
objMessage = objPOP3Client.GetMessage(intMessageNumber);
Process email content
Now, you can process email content for your own process. For, example insert email message into the database for further processing.
Complete example
For the complete example, I have prepared and uploaded a cs file which contains all the code.
- References, Page load, Model, Table
- Get all emails and set in table
- Get email content
- Set email content in table
- Output




Get all emails and set in table

Get email content

Set email content in table

Output

Summary
Now, I believe you will be able to perform email parsing with OpenPop.Pop3 (OpenPop.NET).

RyderPosted Feb 7, 2020, 5:46 AM
Nice article...
Prajesh TalpadePosted Jan 13, 2020, 1:07 AM
Can you please provide the download link for this project.
Prajesh TalpadePosted Jan 13, 2020, 12:37 AM
How can I read email received from a particular email id and save it to database?? Please note I want to read emails received from that perticular email id only.
Dhruvik SathvaraPosted Oct 10, 2019, 1:21 AM
Nice article..
Chittaranjan SwainPosted Sep 30, 2019, 1:44 AM
Nice one....
Arvind PatelPosted Sep 26, 2019, 7:06 AM
Nice article...!!
umed aliPosted Sep 12, 2019, 2:19 AM
Nice article
KEVAL GOHILPosted Sep 11, 2019, 3:04 AM
Helpful Article.
Jignesh SutharPosted Sep 11, 2019, 12:34 AM
Nice Article thanks for sharing.
Jaykishan VaghelaPosted Sep 11, 2019, 12:28 AM
Nice article
Arvind KatariaPosted Sep 10, 2019, 12:30 AM
Nice Information ..!!
Janak ThakkarPosted Sep 9, 2019, 11:15 PM
Good Article very helpful