日期:2014-05-19  浏览次数:21124 次

C#编写邮件客户端程序需要哪些知识
我要用C#编写邮件客户端程序,不知道需要哪些知识,我对C#的各个命名空间不是很熟悉,好像有个System.Net.Mail(System.Net.Mail   命名空间包含用于将电子邮件发送到简单邮件传输协议   (SMTP)   服务器进行传送的类。)   命名空间是是SMTP的,我要用POP3接收邮件,是那个命名空间下?  
还有多媒体邮件的MIME呢   ?  

高手求救

------解决方案--------------------
using System.Net.Sockets;网络通信与会话..
using System.Threading ;多线程处理
using System.Data;数据库连接
这些都是必不可少的.
System.Net.Mail 刚才核实了一下C#中在NET.下面没有MAIL这个空间.
最主要的是NET.SOCKETS这个类.
------解决方案--------------------
以下为发送邮件的类

using System;
using System.Web.Mail;

namespace neillove.Mail
{
/// <summary>
/// DotNetSendMail 的摘要说明。
/// </summary>
public class DotNetSendMail:AbstractSendEmail
{
public DotNetSendMail()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

public override void Send(EmailInfo emailInfo)
{
string smtpServer = System.Configuration.ConfigurationSettings.AppSettings[ "SmtpServer "];
string fromEmal = System.Configuration.ConfigurationSettings.AppSettings[ "FromEmail "];
string loginName = System.Configuration.ConfigurationSettings.AppSettings[ "LoginUserName "];
string loginPwd = System.Configuration.ConfigurationSettings.AppSettings[ "LoginUserPassword "];

//如果没有填写发件人,则取系统管理员帐号发送
if(emailInfo.Sender == null || emailInfo.Sender == string.Empty)
{
emailInfo.Sender = fromEmal;
}

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();

// 设置email的 'from '和 'to '的地址
mail.From =emailInfo.Sender;
mail.To = emailInfo.Receiver;
//mail.Cc = "dsfddf@tom.com ";

mail.Subject = emailInfo.Title;

// 可选: 使用html格式的Email
mail.BodyFormat = MailFormat.Html;

// 可选: 对邮件进行加密
// mailObj.BodyEncoding = MailFormat.Base64;

// 可选: 设置邮件的优先级别为高
mail.Priority = MailPriority.High;

mail.Body = emailInfo.Body;

//添加附件
if(emailInfo.Accessories != null)
{
foreach(string attachment in emailInfo.Accessories)
{
mail.Attachments.Add(new MailAttachment(attachment));
}
}
// 使用SmtpMail对象来发送邮件。
mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");//basic authentication
mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", loginName);// " "); //set your username here
mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", loginPwd);// " ");//set your password here

SmtpMail.SmtpServer = smtpServer; //your real server goes here


SmtpMail.Send(mail);
}


}
}

------解决方案--------------------
smtp pop3 协议 邮件编码