VS.NET 2010 (and above) Users Click Here   

Licensing FAQ
Software Updates
Support Forums
Feature Requests
About Us
Contact Us
Hosting Companies
Privacy Policy
Shopping Cart


aspNetPOP3 and aspNetEmail: Creating an email "Proxy" to process and resend email

by Dave 27. September 2011 13:44

Ian (on the forums) had a question about how to download email from a POP3 server, process it using his own custom rules, and then resending it.

The trick to resending it, is that he wanted to the original email to be resent and unmodified. This is a little different than the usual request. Usually, developers need to modify the original email in some fashion, rebuild it, and resend it.

In this example, Ian wanted to resend the email, as if it's never been sent. It needs to dynamically determine who to send it to, and forward it on. This makes his application work like an email proxy of sorts.

Below is a code example that would get Ian started on something like this.

As always, if anyone has any questions about this, feel free to use the Contact Us page, to send any questions.


Here is the code

void Execute()
	//connect to the pop3 server
	POP3 pop = new POP3();
	pop.Server = "mail.blah.com";
	pop.Username = "dave@blah.com";
	pop.Password = "test";

	//enable logging
	pop.LogPath = "c:\\pop.log";


	//get the first message as text
	string content = pop.GetMessageAsText(0);

	//process the message
	Process( content );
	ResendAsOriginal( content );

	//if we want to delete the message, uncomment the following lines


void Process( string emailContent )
	//create the MimeMessage
	MimeMessage m = MimeMessage.ParseString( emailContent );

	//do whatever we need to with the extracted data
	if( m.Subject  != null )
		string subject = m.Subject.Value;

void ResendAsOriginal( string emailContent )
	//create the EmailMessage object
	EmailMessage msg = new EmailMessage();

	//set the server
	msg.Server = "";

	//set the TO and FROM values
	//these may need to be dynamic, and depend up on the
	//value of emailContent
	//for this example, they are hard coded

	msg.To = "CustomerService@blah.com";
	msg.FromAddress = "proxy@myserver.com";
	msg.SmtpData = emailContent;


Moving email in aspNetPOP3 across folders

by Dave 14. February 2011 04:38

I had a great question from Robert today.  He sent me the following question:

We are currently testing the aspNetPOP3 product. I might be missing the obvious, but I didn’t find where I could get an email, and then move it to a folder. Is this possible?

That's a great question. Usually someone will ask this, or a similar question every few months.

aspNetPOP3 implements the POP3 protocol. Everything that is possible by the POP3 protocol, is possible in aspNetPOP3. 

As far as internet standards go, the POP3 protocol is pretty old. POP3 stands for Post Office Protocol version 3.  It was developed in 1984. 

POP3 has no concept of folders. In the POP3 (and consequently aspNetPOP3) world, there is only the Inbox.  When you see additional folders in POP3 mail clients (such as Outlook, Outlook Express, Eudora, etc..) when you are actually seeing is a client side feature/functionality.  When you move an email from the Inbox to a different folder, what your mail client is actually doing is deleting the message from the server, and moving the message to a local folder. Once that happens, it is no longer accessible via the POP3 protocol.

The same thing happens with webmail clients such as Gmail. (Although, gmail is a little different because it implements something called labels.) . Once the message is moved to a different folder (or label) in the webclient, you no longer have access to that message. Using the POP3 protocol, you can only get at messages in the Inbox.

Once again, great question Robert.

If anyone else has any other questions, comments or feedback relating to aspNetPOP3, feel free to contact me.

Dave Wanta




Thanks for making great products. My staff really likes using your stuff. "

Stephen | Tallent

Read more testimonials
ListNanny aspNetDNS aspNetEmail aspNetPOP3 aspNetMX IPMuncher aspNetMIME aspNetPING aspNetTraceRoute aspNetIMAP aspNetMHT