MailBee.NET是一款强健且功能丰富的邮件创建、接收、处理控件,可以快速帮助开发人员构建复杂的邮件收发和处理系统,支持多种邮件收发协议:SMTP/ESMTP、POP3、IMAP/IDLE/XLIST、HTTP、SSL/TLS、SASL、NTLM、Kerberos、SOCKS4/5、HTTP Proxy,支持多种邮件格式:MIME/.EML、 .MHT、Outlook .MSG、Outlook .PST、XML、HTML、RTF、MS TNEF、vCard、iCal、PDF,以及多种邮件服务器之间的数据交互,这篇文章主要介绍怎么在asp.NET WEB应用收发邮件,具体可以参考下面的代码:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MailBee;
using MailBee.Mime;
using MailBee.SmtpMail;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Smtp mailer = new Smtp();
mailer.SmtpServers.Add("mail.here.com", "john.doe", "secret");
mailer.From.AsString = "John Doe <john.doe@here.com>";
mailer.To.AsString = "Jane Doe <jane.doe@there.com>";
mailer.Subject = "Requested document";
mailer.BodyPlainText = "See the document attached";
if (FileUpload1.HasFile)
{
mailer.Message.Attachments.Add(
FileUpload1.FileBytes, FileUpload1.FileName,
null, null, null,
NewAttachmentOptions.None, MailTransferEncoding.Base64);
}
mailer.Send();
Response.Write("Sent to: " +
Server.HtmlEncode(mailer.GetAcceptedRecipients().ToString()));
}
}
上面的代码主要应用于asp.net下发送带附件的邮件,开发人员可以从
控件中国网上下载该产品的试用版进行测试。