4AspNet POP3 .NET Component

EmailMessage.ToString Method 

Exports EmailMessage object to string. Can be used to save emails as text files.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();

Return Value

String

Example

This sample shows how to use the ToString() method to save emails from POP3 server as .eml files

ForAspNet.POP3.License.LicenseKey = "<put license string here>";
POP3 objPOP3 = new POP3("mail.server.com", "login", "password");
objPOP3.Connect()
if (objPOP3.IsAPOPSupported)
    objPOP3.SecureLogin();
else
    objPOP3.Login();
objPOP3.QueryServer();
for (int i = 1; i <= objPOP3.TotalMailCount; i++)
{
    EmailMessage objEmail = objPOP3.GetMessage(i, false);
    StreamWriter sw = new StreamWriter(@"c:\\pop3\m_" + objEmail.GetCustomHeader("Message-ID") + ".eml");
    sw.Write(objEmail.ToString());
    sw.Close();
}
objPOP3.Close();

See Also

EmailMessage Class | ForAspNet.POP3 Namespace