因公司使用.net语言开发的开源工作流ccflow,此工作流只能发送内部邮件所以只能在其源码上新增能够发送和接收外部邮件的方法,发送邮件还是比较好整的,接收邮件第一次做还是遇到了不少问题,在网上搜了资料发现大多资料都是一样的Copy来Copy去的,以下是整理后的发送邮件和接收邮件的实例,经测试通过,附上程序压缩包,首先使用smtp发送邮件,此方法可发送附件。
/// <summary> /// 发送邮件 /// </summary> /// <param name="userEmail">邮件实体</param> /// <param name="receiver">接收者邮件地址</param> /// <param name="title">邮件主题</param> /// <param name="content">邮件内容</param> /// <param name="AttachFile">附件地址</param> /// <param name="dictionary">附件名称集合</param> protected void sendOutEMails(UserMail userEmail, String receiver, String title, String content, String AttachFile, Dictionary<int, String> dictionary) { try { // SMTP服务器 string smtpHost = "smtp." + userEmail .smtpServer+ ".com"; // SMTP服务器端口 int smtpPort = userEmail.smtpProt; // 发送者邮件地址 string senderEmail = userEmail.MailUser; // 发送者名字 string senderName = BP.Web.WebUser.Name; // 接收者邮件地址 string recipientEmail; String[] emailArr = receiver.Split('<'); if (emailArr.Length > 1) { recipientEmail = emailArr[emailArr.Length-1].Replace("<", "").Replace(">", "").Replace("《","").Replace("》",""); } else { recipientEmail = receiver; } //string recipientEmail = receiver;// "xiecanaas@126.com"; // 主题 string subject = title; // 邮件内容 string body = content; SmtpConfig.VerifyAddresses = false; EmailAddress from = new EmailAddress(senderEmail, senderName); EmailAddress to = new EmailAddress(recipientEmail); MailMessage msg = new MailMessage(from, to); // 这行一定要填上,不然收到的中文邮件是一连串的??????? msg.Charset = "UTF-8"; msg.Subject = subject; msg.Body = body; //添加附件 Attachment attachment = null; msg.Attachments.Clear(); //判断附件不为空 if (!String.IsNullOrEmpty(AttachFile)) { String[] attachPath= AttachFile.Split(';'); for (int i = 0; i < attachPath.Length-1; i++) { String pathFileName = attachPath[i]; string extName = Path.GetExtension(pathFileName).ToLower(); //获取扩展名 FileStream fs = new FileStream(Server.MapPath("/") + pathFileName, FileMode.Open, FileAccess.Read); //将附件添加到mailmessage对象 attachment = new Attachment(fs, dictionary[i]); msg.AddAttachment(attachment); } } Smtp smtp = new Smtp(smtpHost, smtpPort); // 在SMTP服务器上的用户名和密码 smtp.Username = userEmail.MailUser; smtp.Password = userEmail.MailPass; smtp.SendMail(msg); StringBuilder toList = new StringBuilder(); for (IEnumerator i = msg.To.GetEnumerator(); i.MoveNext(); ) { EmailAddress a = (EmailAddress)i.Current; toList.Append(a.Address + ";"); } } catch (MalformedAddressException mfa) { //异常处理 mfa.ToString(); } catch (SmtpException se) { //异常处理 se.ToString(); } catch (Exception ex) { //异常处理 ex.ToString(); } }
接收邮件
/// <summary> /// 外部邮箱邮件记录 /// </summary> private void ReceiveOutMails() { private readonly Pop3Client pop3Client = new Pop3Client(); object sysobj = new Object(); //while (true) //{ lock (sysobj) { try { if (pop3Client.Connected) pop3Client.Disconnect(); String code = LOGINUSER; String sqlString = String.Format("select * from OA_UserMail where UserCode='{0}' ", LOGINUSER); System.Data.DataSet dt = BP.DA.DBAccess.RunSQLReturnDataSet(sqlString); String test = dt.Tables[0].Rows[0]["popServer"].ToString(); String test2 = dt.Tables[0].Rows[0]["MailUser"].ToString(); String test3 = dt.Tables[0].Rows[0]["MailPass"].ToString(); if (dt.Tables[0].Rows.Count > 0) { //根据数据库设置获取收件服务器地址 pop3Client.Connect("pop." + dt.Tables[0].Rows[0]["popServer"].ToString() + ".com", 110, false); pop3Client.Authenticate(dt.Tables[0].Rows[0]["MailUser"].ToString(), dt.Tables[0].Rows[0]["MailPass"].ToString()); } else { return; } //通过pop对象获取信息总条数 int count = pop3Client.GetMessageCount(); int success = 0; int fail = 0; string AttachFile = null; //取得请求过来的文件结合,以下是读取邮箱邮件存储到本地 for (int i = count; i >= 1; i -= 1) { try { //得到单个Message对象 OpenPop.Mime.Message message = pop3Client.GetMessage(i); //根据MessageIdEx判断这个邮件是否已经读取 string sSql = String.Format("select * from OA_MessageEX where MessageId='{0}' ", message.Headers.MessageId); System.Data.DataSet dataSet = BP.DA.DBAccess.RunSQLReturnDataSet(sSql); //根据MessageId获取的数据集为空则证明没读取过本条记录 if (dataSet.Tables[0].Rows.Count <= 0) { //取得所有当前文件的附件集合 List<MessagePart> attachments = message.FindAllAttachments(); if (attachments.Count > 0) { //循环附件 foreach (MessagePart attachment in attachments) { //生成地址 string dir = this.GetAttachPathName(); if (!System.IO.Directory.Exists(Server.MapPath(dir))) System.IO.Directory.CreateDirectory(Server.MapPath(dir)); //文件名称 string newFileName = this.GetAttachFileName(attachment.FileName); //文件路径 string path = String.Format("{0}/{1}", dir, newFileName); //string filePath = this.FileUpload1.PostedFile.FileName; WebClient myWebClient = new WebClient(); myWebClient.Credentials = CredentialCache.DefaultCredentials; try { //打开远程Web地址,将文件流写入 Stream postStream = myWebClient.OpenWrite(Server.MapPath("/") + path, "PUT"); if (postStream.CanWrite) { postStream.Write(attachment.Body, 0, attachment.Body.Length); } else { //MessageBox.Show("Web服务器文件目前不可写入,请检查Web服务器目录权限设置!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Information); } postStream.Close();//关闭流 AttachFile += String.Format("{0};", path); } catch { ; } } //清除邮件集合 attachments.Clear(); } //新增邮件信息表 MessagePart plainTextPart = message.FindFirstPlainTextVersion(); BP.OA.Message.Message msg = new BP.OA.Message.Message(); DateTime AddTime = DateTime.Now; //判断内容区域是否为文字类型 String Doc=""; try { Doc = plainTextPart.GetBodyAsText(); } catch (Exception) { Doc = "<<OpenPop>> Cannot show this part of the email. It is not text <<OpenPop>>"; } String FK_UserNo = LOGINUSER; int MessageState = 1; String SendToUsers = ""; String CopyToUsers = ""; System.Data.DataSet messageData = this.getMaxOID(); String OID = messageData.Tables[0].Rows[0]["OID"].ToString(); if (message.Headers.To.Count > 0) foreach (RfcMailAddress to in message.Headers.To) SendToUsers += String.Format("{0},", to).TrimEnd(','); if (message.Headers.Cc.Count > 0) foreach (RfcMailAddress cc in message.Headers.Cc) CopyToUsers += String.Format("{0},", cc).TrimEnd(','); String AttachFiles = AttachFile; String Title = message.Headers.Subject; String MessageIdEx = message.Headers.MessageId; //插入数据到OA_Message String messageInsertSql = String.Format("Insert into OA_Message (AddTime,Title,AttachFile,Doc,FK_UserNo,MessageState,SendToUsers,CopyToUsers,MessageIdEx,OID) values('{0}','{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}',{9})", AddTime, Title, AttachFiles, Doc, FK_UserNo, MessageState, SendToUsers, CopyToUsers, MessageIdEx, Convert.ToInt32(OID) + 1); doNonQuery(messageInsertSql); //插入数据到OA_MessageEX String messageExSql = String.Format("Insert into OA_MessageEX (MessageId) values('{0}')", message.Headers.MessageId); doNonQuery(messageExSql); //msg.Insert(); //附件地址插入成功后将地址清空 AttachFile = null; //if (msg.OID == 0) //{ // this.Alert("邮件读取失败!"); return; //} #region 插入数据到收件箱表 if (true) { //获取OA_MessageInBox表最大OID System.Data.DataSet messageInBoxData = this.getOA_MessageInBoxMaxOID(); String maxOA_MessageInBoxOID = messageInBoxData.Tables[0].Rows[0]["OID"].ToString(); foreach (RfcMailAddress to in message.Headers.To) { if (String.Format("{0},", to).IndexOf("@") > 0) { //收件箱 n个人 //获取OA_Message表最大OID System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; String FK_MsgNo = dataSets.Tables[0].Rows[0]["OID"].ToString(); String FK_ReceiveUserNo = to.ToString(); String Sender = message.Headers.From.ToString(); //Boolean Received = false; //Boolean IsCopy = false; //是否抄送标志 String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy,OID) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 0, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); //ib.Insert(); } else { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"].ToString());; String FK_ReceiveUserNo = String.Format("{0},", to); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = false; //是否抄送标志 //ib.Insert(); String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 0, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); int newId = dataSets.Tables[0].Rows[0]["OID"].ToString() !="" ? Convert.ToInt32( dataSets.Tables[0].Rows[0]["OID"]):0; if (newId == 0) continue; } } } #endregion #region 插入数据到收件箱主题表 if (true) { //获取OA_MessageInBox表最大OID System.Data.DataSet messageInBoxData = this.getOA_MessageInBoxMaxOID(); String maxOA_MessageInBoxOID = messageInBoxData.Tables[0].Rows[0]["OID"].ToString(); //发送给抄送人 foreach (RfcMailAddress cc in message.Headers.Cc) { if (String.Format("{0},", cc).IndexOf("@") > 0) { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32( dataSets.Tables[0].Rows[0]["OID"].ToString()); ; String FK_ReceiveUserNo = String.Format("{0},", cc); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = true; //是否抄送标志 String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 1, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); // ib.Insert(); } else { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"].ToString()); String FK_ReceiveUserNo = String.Format("{0},", String.Format("{0},", cc)); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = true; //是否抄送标志 // ib.Insert(); String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 1, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); int newId = dataSets.Tables[0].Rows[0]["OID"].ToString() != "" ? Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"]) : 0; if (newId == 0) continue; } } } #endregion success++; } } catch (Exception e) { DefaultLogger.Log.LogError( "TestForm: Message fetching failed: " + e.Message + "\r\n" + "Stack trace:\r\n" + e.StackTrace); fail++; } ; } if (fail > 0) { this.Alert("邮件读取失败!"); return; } } catch (InvalidLoginException) { ; } catch (PopServerNotFoundException) { ; } catch (PopServerLockedException) { ; } catch (LoginDelayException) { ; } catch (Exception e) { ; } ; } }
openpop 接收邮件
// 声明成员变量 private readonly Pop3Client pop3Client = new Pop3Client(); /// <summary> /// 外部邮箱邮件记录 /// </summary> private void ReceiveOutMails() { private readonly Pop3Client pop3Client = new Pop3Client(); object sysobj = new Object(); //while (true) //{ lock (sysobj) { try { if (pop3Client.Connected) pop3Client.Disconnect(); String code = LOGINUSER; String sqlString = String.Format("select * from OA_UserMail where UserCode='{0}' ", LOGINUSER); System.Data.DataSet dt = BP.DA.DBAccess.RunSQLReturnDataSet(sqlString); String test = dt.Tables[0].Rows[0]["popServer"].ToString(); String test2 = dt.Tables[0].Rows[0]["MailUser"].ToString(); String test3 = dt.Tables[0].Rows[0]["MailPass"].ToString(); if (dt.Tables[0].Rows.Count > 0) { //根据数据库设置获取收件服务器地址 pop3Client.Connect("pop." + dt.Tables[0].Rows[0]["popServer"].ToString() + ".com", 110, false); pop3Client.Authenticate(dt.Tables[0].Rows[0]["MailUser"].ToString(), dt.Tables[0].Rows[0]["MailPass"].ToString()); } else { return; } //通过pop对象获取信息总条数 int count = pop3Client.GetMessageCount(); int success = 0; int fail = 0; string AttachFile = null; //取得请求过来的文件结合,以下是读取邮箱邮件存储到本地 for (int i = count; i >= 1; i -= 1) { try { //得到单个Message对象 OpenPop.Mime.Message message = pop3Client.GetMessage(i); //根据MessageIdEx判断这个邮件是否已经读取 string sSql = String.Format("select * from OA_MessageEX where MessageId='{0}' ", message.Headers.MessageId); System.Data.DataSet dataSet = BP.DA.DBAccess.RunSQLReturnDataSet(sSql); //根据MessageId获取的数据集为空则证明没读取过本条记录 if (dataSet.Tables[0].Rows.Count <= 0) { //取得所有当前文件的附件集合 List<MessagePart> attachments = message.FindAllAttachments(); if (attachments.Count > 0) { //循环附件 foreach (MessagePart attachment in attachments) { //生成地址 string dir = this.GetAttachPathName(); if (!System.IO.Directory.Exists(Server.MapPath(dir))) System.IO.Directory.CreateDirectory(Server.MapPath(dir)); //文件名称 string newFileName = this.GetAttachFileName(attachment.FileName); //文件路径 string path = String.Format("{0}/{1}", dir, newFileName); //string filePath = this.FileUpload1.PostedFile.FileName; WebClient myWebClient = new WebClient(); myWebClient.Credentials = CredentialCache.DefaultCredentials; try { //打开远程Web地址,将文件流写入 Stream postStream = myWebClient.OpenWrite(Server.MapPath("/") + path, "PUT"); if (postStream.CanWrite) { postStream.Write(attachment.Body, 0, attachment.Body.Length); } else { //MessageBox.Show("Web服务器文件目前不可写入,请检查Web服务器目录权限设置!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Information); } postStream.Close();//关闭流 AttachFile += String.Format("{0};", path); } catch { ; } } //清除邮件集合 attachments.Clear(); } //新增邮件信息表 MessagePart plainTextPart = message.FindFirstPlainTextVersion(); BP.OA.Message.Message msg = new BP.OA.Message.Message(); DateTime AddTime = DateTime.Now; //判断内容区域是否为文字类型 String Doc=""; try { Doc = plainTextPart.GetBodyAsText(); } catch (Exception) { Doc = "<<OpenPop>> Cannot show this part of the email. It is not text <<OpenPop>>"; } String FK_UserNo = LOGINUSER; int MessageState = 1; String SendToUsers = ""; String CopyToUsers = ""; System.Data.DataSet messageData = this.getMaxOID(); String OID = messageData.Tables[0].Rows[0]["OID"].ToString(); if (message.Headers.To.Count > 0) foreach (RfcMailAddress to in message.Headers.To) SendToUsers += String.Format("{0},", to).TrimEnd(','); if (message.Headers.Cc.Count > 0) foreach (RfcMailAddress cc in message.Headers.Cc) CopyToUsers += String.Format("{0},", cc).TrimEnd(','); String AttachFiles = AttachFile; String Title = message.Headers.Subject; String MessageIdEx = message.Headers.MessageId; //插入数据到OA_Message String messageInsertSql = String.Format("Insert into OA_Message (AddTime,Title,AttachFile,Doc,FK_UserNo,MessageState,SendToUsers,CopyToUsers,MessageIdEx,OID) values('{0}','{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}',{9})", AddTime, Title, AttachFiles, Doc, FK_UserNo, MessageState, SendToUsers, CopyToUsers, MessageIdEx, Convert.ToInt32(OID) + 1); doNonQuery(messageInsertSql); //插入数据到OA_MessageEX String messageExSql = String.Format("Insert into OA_MessageEX (MessageId) values('{0}')", message.Headers.MessageId); doNonQuery(messageExSql); //msg.Insert(); //附件地址插入成功后将地址清空 AttachFile = null; //if (msg.OID == 0) //{ // this.Alert("邮件读取失败!"); return; //} #region 插入数据到收件箱表 if (true) { //获取OA_MessageInBox表最大OID System.Data.DataSet messageInBoxData = this.getOA_MessageInBoxMaxOID(); String maxOA_MessageInBoxOID = messageInBoxData.Tables[0].Rows[0]["OID"].ToString(); foreach (RfcMailAddress to in message.Headers.To) { if (String.Format("{0},", to).IndexOf("@") > 0) { //收件箱 n个人 //获取OA_Message表最大OID System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; String FK_MsgNo = dataSets.Tables[0].Rows[0]["OID"].ToString(); String FK_ReceiveUserNo = to.ToString(); String Sender = message.Headers.From.ToString(); //Boolean Received = false; //Boolean IsCopy = false; //是否抄送标志 String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy,OID) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 0, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); //ib.Insert(); } else { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"].ToString());; String FK_ReceiveUserNo = String.Format("{0},", to); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = false; //是否抄送标志 //ib.Insert(); String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 0, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); int newId = dataSets.Tables[0].Rows[0]["OID"].ToString() !="" ? Convert.ToInt32( dataSets.Tables[0].Rows[0]["OID"]):0; if (newId == 0) continue; } } } #endregion #region 插入数据到收件箱主题表 if (true) { //获取OA_MessageInBox表最大OID System.Data.DataSet messageInBoxData = this.getOA_MessageInBoxMaxOID(); String maxOA_MessageInBoxOID = messageInBoxData.Tables[0].Rows[0]["OID"].ToString(); //发送给抄送人 foreach (RfcMailAddress cc in message.Headers.Cc) { if (String.Format("{0},", cc).IndexOf("@") > 0) { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32( dataSets.Tables[0].Rows[0]["OID"].ToString()); ; String FK_ReceiveUserNo = String.Format("{0},", cc); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = true; //是否抄送标志 String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 1, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); // ib.Insert(); } else { //收件箱 n个人 System.Data.DataSet dataSets = this.getMaxOID(); AddTime = DateTime.Now; int FK_MsgNo = Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"].ToString()); String FK_ReceiveUserNo = String.Format("{0},", String.Format("{0},", cc)); String Sender = message.Headers.From.ToString(); Boolean Received = false; Boolean IsCopy = true; //是否抄送标志 // ib.Insert(); String inBoxSql = String.Format("Insert into OA_MessageInBox(FK_MsgNo,FK_ReceiveUserNo,Sender,AddTime,Received,IsCopy) values({0},'{1}','{2}','{3}',{4},{5},{6})", FK_MsgNo, FK_ReceiveUserNo, Sender, AddTime, 0, 1, Convert.ToInt32(maxOA_MessageInBoxOID) + 1); doNonQuery(inBoxSql); int newId = dataSets.Tables[0].Rows[0]["OID"].ToString() != "" ? Convert.ToInt32(dataSets.Tables[0].Rows[0]["OID"]) : 0; if (newId == 0) continue; } } } #endregion success++; } } catch (Exception e) { DefaultLogger.Log.LogError( "TestForm: Message fetching failed: " + e.Message + "\r\n" + "Stack trace:\r\n" + e.StackTrace); fail++; } ; } if (fail > 0) { this.Alert("邮件读取失败!"); return; } } catch (InvalidLoginException) { ; } catch (PopServerNotFoundException) { ; } catch (PopServerLockedException) { ; } catch (LoginDelayException) { ; } catch (Exception e) { ; } ; } }
相关推荐
本主题聚焦于使用C语言实现SMTP(Simple Mail Transfer Protocol)邮件发送功能,通过一个名为"OpenSmtp"的开源库。下面我们将深入探讨相关的知识点。 首先,`C_邮件发送`指的是使用C语言编程来实现邮件的发送。...
- **高性能**:OpenSmtp通过优化算法和并发处理能力,能够在短时间内处理大量邮件,尤其适合需要批量发送邮件的应用。 - **稳定性**:由于内置的错误处理机制和重试策略,OpenSmtp在面对网络不稳定或服务器故障时...
OpenSmtp项目是一个开源的SMTP(Simple Mail Transfer Protocol)客户端库,它允许程序员通过编程的方式发送电子邮件。SMTP是互联网标准,用于从一台计算机向另一台计算机传输邮件。OpenSmtp.Mail.dll是这个项目的一...
使用 163 的 SMTP 服务器发送邮件可以使得我们的邮件更容易被用户所接收,而不是被当做垃圾邮件来处理。但是,我们需要遵守 163 的使用条款,并且注意到我们的开发系统所发送的邮件不要被当做垃圾邮件来处理。
SMTP通常用于发送邮件,但不处理接收邮件,因此我们需要结合其他协议来完成完整的邮件交互。 POP3是另一种关键的邮件协议,主要用于从邮件服务器下载邮件。当用户想要查看他们的邮件时,POP3允许客户端与服务器建立...
openSmtp 邮件发送dll 支持中文 ,支持中文文件名 .原版的不支持中文内容和中文附件 ,做过修改
使用LumiSoft.Net和OpenPop分别实现邮件接收(POP3)协议 并且使用了简单工厂模式将其融合。能实现邮件的接收附件的存储,主题、内容、附件、UID、删除邮件等功能。 主要的是可以直接拿过来使用,且都是开源的,最他...
"C# 使用 163 的 SMTP 服务器发送邮件" 在今天的 IT 行业中,发送邮件是非常常见的操作,特别是在Web应用程序中。C# 提供了一个名为 System.Net.Mail.SmtpClient 的类专门用来请求 SMTP 服务器发送邮件。但是,如果...
总的来说,通过VC++实现邮件发送和接收需要理解网络通信的基本概念,熟悉SMTP和POP3协议的命令流程,以及可能使用到的第三方库。实际编程时,要特别注意错误处理和安全性,例如防止中间人攻击和确保数据传输的加密。...
3. **邮件发送模拟**:工具会创建一个测试邮件,包含发件人、收件人、主题和正文,然后尝试通过SMTP服务器发送这个邮件,以此来检查邮件传递路径的畅通性。 4. **错误报告**:如果遇到任何发送问题,如连接失败、...
在IT领域,邮件服务是企业或个人日常通信中不可或缺的一部分,而OpenSMTP作为一个开源的SMTP服务器组件,为开发者提供了一种方便的方式来发送邮件。本文将深入探讨如何解决OpenSMTP 1.11.0版本中关于附件乱码的问题...
开发者需要使用这些功能来建立与SMTP服务器的连接,发送和接收数据。 3. **邮件消息结构**:邮件消息由头部和主体两部分组成,头部包含发件人、收件人、主题等信息,主体则是邮件内容。在易语言中,需要正确构造这...
在Linux系统中,我们可以使用C语言编写SMTP客户端和服务器来实现邮件的发送和接收。本文将深入探讨SMTP协议的基本原理,以及如何使用C语言编写SMTP客户端和服务器。 首先,了解SMTP协议的基本概念至关重要。SMTP...
JMail是一个流行的Java组件,它允许开发者轻松地在Java应用程序中实现邮件的发送和接收功能,包括处理附件。本篇文章将详细探讨如何使用JMail组件来完成邮件的发送与接收,以及如何处理邮件中的附件。 首先,我们来...
发送邮件的基本步骤包括连接SMTP服务器、身份验证、指定发件人和收件人、发送邮件内容以及断开连接。通过telnet工具,我们可以直接与SMTP服务器交互,模拟邮件发送过程。例如,以下是一个简单的telnet示例: ```...
本教程将详细讲解如何使用C++结合SMTP协议来实现邮件发送功能,主要关注对163和126邮箱的支持,以及理论上的QQ邮箱兼容性。 首先,理解SMTP协议的基础知识至关重要。SMTP是基于TCP/IP的应用层协议,通过它,邮件...
本程序是一个使用C++编写的SMTP邮件发送程序,特别地,它包含身份验证功能,使得发送邮件的过程更加安全和可靠。 首先,SMTP类是这个程序的核心,它封装了与SMTP服务器交互的所有必要操作。类的设计通常包括初始化...
总结起来,构建和使用电子邮件发送和接收程序涉及到IIS的安装、SMTP服务器的配置以及对POP3或IMAP4协议的理解。正确设置和使用这些组件,能够实现高效、可靠的电子邮件通信。在实际操作中,还需要注意安全问题,如...
首先,"OpenSmtp"是一个开源的邮件发送库,它提供了C#和C两种编程语言的接口,使得开发者能够方便地在自己的应用程序中集成邮件发送功能。"OpenSmtp.dll"是该库的动态链接库文件,包含了所有必要的功能实现,开发者...