EAGetMail namespace contains classes that allow you to parse and receive email messages. Parseing email message, winmail.dat (TNEF) and encrypted message becomes very easily. The classes in this namespace can be used from ASP.NET or any managed application.
Classes
| Class | Description |
| Attachment | Provides properties and methods for presenting e-mail attachment. |
| Certificate | Provides properties and methods for presenting a digital certificate. |
| HeaderCollection | Collection of HeaderItem class inherited from System.Collections.ArrayList |
| HeaderItem | Provides properties and methods for presenting an e-mail header. |
| Imap4Folder | Provides properties and methods for presenting an IMAP4 folder. |
| Provides properties and methods for presenting an e-mail message. | |
| MailAddress | Provides properties and methods for presenting an e-mail address including display name, e-mail address. |
| MailClient | Provides properties and methods for receiving messages and managing IMAP4 folder. |
| MailInfo | Provides properties and methods for presenting an e-mail information(size, uidl, flags) on mail server. |
| MailServer | Provides properties and methods for constructing a pop3/imap4 server instance. |
| MailServerException | Represents errors that is returned by pop3/imap server. |
| ClientTerminatedException | Represents error that sending email is cancelled by user. |
| ProxyServerException | Represents errors that is returned by proxy server.. |
Enumerations
| Enumeration | Description |
| MailPriority | Presents the priority level for the e-mail message. |
| ServerAuthType | Specifies the pop3/imap4 user authentication mechanism. |
| ServerProtocol | Specifies the protocol (POP3/IMAP4) for mail server. |
| SocksProxyProtocol | Specifies the protocol (socks4/socks5/http) for proxy server. |
Example
[Visual Basic, C#, C++] The following example demonstrates how to receive email with EAGetMail POP3 & IMAP Component, but it doesn't demonstrates the events and mail parsing usage. To get the full samples of EAGetMail, please refer to Samples section.
[Visual Basic]
Imports EAGetMail
Public Sub ReceiveMail( _
ByVal sServer As String, _
ByVal sUserName As String, _
ByVal sPassword As String, _
ByVal bSSLConnection As Boolean)
Dim oClient As New MailClient("TryIt")
'To receive email from imap4 server, please change
'ServerProtocol.Pop3 to ServerProtocol.Imap4 in MailServer constructor
Dim oServer As New MailServer(sServer, _
sUserName, sPassword, bSSLConnection, _
ServerAuthType.AuthLogin, ServerProtocol.Pop3)
'by default, the pop3 port is 110, imap4 port is 143,
'the pop3 ssl port is 995, imap4 ssl port is 993
'you can also change the port like this
'oServer.Port = 110
Try
oClient.Connect(oServer)
Dim infos() As MailInfo = oClient.GetMailInfos()
Dim count As Integer = infos.Length
For i As Integer = 0 To count - 1
Dim info As MailInfo = infos(i)
Dim oMail As Mail = oClient.GetMail(info)
''Save mail to local file
oMail.SaveAs(String.Format("c:\{0}.eml", i), True)
Next
For i As Integer = 0 To count - 1
Dim info As MailInfo = infos(i)
oClient.Delete(info)
Next
'
' Delete method just mark the email as deleted,
' Quit method pure the emails from server exactly.
oClient.Quit()
Catch ep As MailServerException
''Message contains the information returned by mail server
Console.WriteLine("Server Respond: {0}", ep.Message)
Catch ep As System.Net.Sockets.SocketException
Console.WriteLine("Socket Error: {0}", ep.Message)
Catch ep As Exception
Console.WriteLine("System Error: {0}", ep.Message)
End Try
oClient.Close()
End Sub
[C#]
using System;
using System.Collections;
using EAGetMail;
public void ReceiveMail(
string sServer,
string sUserName,
string sPassword,
bool bSSLConnection)
{
MailClient oClient = new MailClient("TryIt");
//To receive email from imap4 server, please change
//ServerProtocol.Pop3 to ServerProtocol.Imap4 in MailServer constructor
MailServer oServer = new MailServer(sServer,
sUserName, sPassword, bSSLConnection,
ServerAuthType.AuthLogin, ServerProtocol.Pop3);
//by default, the pop3 port is 110, imap4 port is 143,
//the pop3 ssl port is 995, imap4 ssl port is 993
//you can also change the port like this
//oServer.Port = 110;
try
{
oClient.Connect(oServer);
MailInfo [] infos = oClient.GetMailInfos();
int count = infos.Length;
for( int i = 0; i < count; i++ )
{
MailInfo info = infos[i];
Mail oMail = oClient.GetMail(info);
//Save mail to local file
oMail.SaveAs(String.Format("c:\\{0}.eml", i), true);
}
for( int i = 0; i < count; i++ )
{
MailInfo info = infos[i];
oClient.Delete(info);
}
// Delete method just mark the email as deleted,
// Quit method pure the emails from server exactly.
oClient.Quit();
}
catch( MailServerException ep )
{
//Message contains the information returned by mail server
Console.WriteLine("Server Respond: {0}", ep.Message);
}
catch( System.Net.Sockets.SocketException ep )
{
Console.WriteLine("Socket Error: {0}", ep.Message);
}
catch( Exception ep )
{
Console.WriteLine("System Error: {0}", ep.Message);
}
oClient.Close();
}
[C++]
using namespace System;
using namespace System::Collections;
using namespace EAGetMail;
Void ReceiveMail(
String *sServer,
String *sUserName,
String *sPassword,
bool bSSLConnection)
{
MailClient *oClient = new MailClient(S"TryIt");
//To receive email from imap4 server, please change
//ServerProtocol::Pop3 to ServerProtocol::Imap4 in MailServer constructor
MailServer *oServer = new MailServer(sServer,
sUserName, sPassword, bSSLConnection,
ServerAuthType::AuthLogin, ServerProtocol::Pop3);
//by default, the pop3 port is 110, imap4 port is 143,
//the pop3 ssl port is 995, imap4 ssl port is 993
//you can also change the port like this
//oServer->Port = 110;
try
{
oClient->Connect(oServer);
MailInfo *infos[]= oClient->GetMailInfos();
int count = infos->Length;
for( int i = 0; i < count; i++ )
{
MailInfo *info = infos[i];
Mail *oMail = oClient->GetMail(info);
//Save mail to local file
oMail->SaveAs(String::Format(S"c:\\{0}.eml", __box(i)), true);
}
for( int i = 0; i < count; i++ )
{
MailInfo *info = infos[i];
oClient->Delete(info);
}
// Delete method just mark the email as deleted,
// Quit method pure the emails from server exactly.
oClient->Quit();
}
catch( MailServerException *ep )
{
//Message contains the information returned by mail server
Console::WriteLine( S"Server Respond: {0}", ep->Message);
}
catch( System::Net::Sockets::SocketException *ep )
{
Console::WriteLine( S"Socket Error: {0}", ep->Message);
}
catch( Exception *ep )
{
Console::WriteLine( S"System Error: {0}", ep->Message);
}
oClient->Close();
}