Email操作之Aspose.Email--POP3

Creating My First Aspose.Email.Pop3 Application

//Create a pop3 client
Aspose.Email.Pop3.Pop3Client client;
client = new Aspose.Email.Pop3.Pop3Client();

//Basic settings (required)
client.Host = "pop3.youdomain.com";
client.Username = "username";
client.Password = "psw";
//Connect and login to Pop3 server
try { client.Connect(); client.Login(); } catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

//Retrieve Message
try
{
    //mail parser
    Aspose.Email.Mail.MailMessage msg;

    //retrieve first message in MailMessage format directly
    msg = client.FetchMessage(1);
    txtFrom.Text = msg.From.ToString();
    txtSubject.Text = msg.Subject.ToString();
    txtBody.Text = msg.HtmlBody.ToString();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
//Disconnect from Pop3 server
try
{
    client.Disconnect();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

For SSL enabled servers, we need to change the following properties of the Pop3Client object

// set implicit security mode
client.SecurityMode = Aspose.Email.Pop3.Pop3SslSecurityMode.Implicit;
// enable SSL
client.EnableSsl = true;

 

 

其它详见:http://www.aspose.com/docs/display/emailnet/Load+Smtp+Authentication+Information+from+Config+File

posted on 2013-06-10 00:43  vvangjian  阅读(1307)  评论(0编辑  收藏  举报