上一篇c#和outlook发送邮件使用的file类的部分代码
来源:互联网 发布:淘宝开团是不是很难抢 编辑:程序博客网 时间:2024/05/22 00:45
主要使用的4个类代码,ReadFile,WriteFile,Net_Email,SysLogAdd
public class File { private const string connectionString = "Server=10.00.00.00;Database=CwtTripSep;UID=00;PWD=000;Enlist=true;Pooling=true;Max Pool Size=512;Min Pool Size=0;Connection Lifetime=300;packet size=2000"; public static string ReadFile(string FilePath, string Encode = "GB2312") { string StrTemp = ""; try { if (System.IO.File.Exists(FilePath)) StrTemp = System.IO.File.ReadAllText(FilePath, Encoding.GetEncoding(Encode)); } catch (Exception) { StrTemp = ""; } return StrTemp; } public static void SysLogAdd(int strLogType, string strLogUser, int strLogUserType, string strLogContent, string strLogIP) { List<string> SQL = new List<string>(); StringBuilder LogSql = new StringBuilder(); LogSql.Append("INSERT INTO [T_SysLog] (LogType,LogUser,LogUserType,LogContent,LogIP) "); LogSql.Append("values ("); LogSql.Append("" + strLogType + ","); LogSql.Append("'" + strLogUser + "',"); LogSql.Append("" + strLogUserType + ","); LogSql.Append("'" + strLogContent + "',"); LogSql.Append("'" + strLogIP + "'"); LogSql.Append(")"); SQL.Add(LogSql.ToString()); ExecuteSqlTran(SQL); } public static void WriteFile(string FilePath, string FileInfo, string Encode = "GB2312") { try { if (System.IO.File.Exists(FilePath)) System.IO.File.Delete(FilePath); System.IO.File.WriteAllText(FilePath, FileInfo, Encoding.GetEncoding(Encode)); } catch (Exception) { } } public static string Net_Email(string strSendto, string strCC, string strBCC, string strMailContent, string strMailTitle, string[] strMailAttachMent, string strMailFormat, string strServiceTeam) { try { MailMessage mMail = new MailMessage(); using (mMail) { strMailContent = strMailContent.Replace("<br>\n", "<br>"); string[] ListTo = strSendto.Split(';'); for (int i = 0; i < ListTo.Length; i++) { if (ListTo[i].Equals("")) continue; mMail.To.Add(ListTo[i]); } string[] ListCC = strCC.Split(';'); for (int i = 0; i < ListCC.Length; i++) { if (ListCC[i].Equals("")) continue; mMail.CC.Add(ListCC[i]); } string[] ListBCC = strBCC.Split(';'); for (int i = 0; i < ListBCC.Length; i++) { if (ListBCC[i].Equals("")) continue; mMail.Bcc.Add(ListBCC[i]); } string[] strMailFrom = strServiceTeam.Split(';'); mMail.From = strMailFrom[0].IndexOf("@", StringComparison.Ordinal) > 1 ? new MailAddress(strMailFrom[0]) : new MailAddress("OFC@carlsonwagonlit.com.cn"); mMail.Body = strMailContent; mMail.Subject = strMailTitle; mMail.IsBodyHtml = strMailFormat == ""; for (int i = 0; i < strMailAttachMent.Length; i++) { string strFJ = strMailAttachMent[i] + ""; if (strFJ.Length > 0) { mMail.Attachments.Add(new Attachment(strFJ)); } } SmtpClient smtp = new SmtpClient(); smtp.Host = "10.180.84.51"; smtp.Credentials = new NetworkCredential("emailcn", "Carlson123"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(mMail); return "1"; } } catch (Exception ex) { return ex.Message; } } }
阅读全文
0 0
- 上一篇c#和outlook发送邮件使用的file类的部分代码
- C#邮件发送的系统部分代码
- 通过Outlook编辑和发送邮件的VBS脚本
- 删除Outlook 2007中重复邮件的C#代码
- C# 调用outlook 发送邮件
- c# 调用outlook发送邮件
- C#通过Outlook发送邮件
- OUTLOOK不能发送邮件的原因
- 取消outlook正在发送的邮件
- Outlook中撤回已发送的邮件
- 一些关于C#发送邮件的代码
- 一些关于C#发送邮件的代码
- 使用c#给outlook添加任务、发送邮件
- C#发送邮件的类
- flex 使用outlook发送邮件
- C#的发送邮件
- 针对C#调用OutLook发送邮件模块出现的各类问题解决方案
- 发送邮件的代码~
- mybatis查询出来的字段的值为null,驼峰字段
- sql语句的各种模糊查询
- Android开发,ZxMvp框架的引入及使用详解(上)
- 第二周 项目3—汉诺塔
- 第二周实践项目三(1)
- 上一篇c#和outlook发送邮件使用的file类的部分代码
- 从头到尾解析Hash 表算法 作者:July、wuliming、pkuoliver 出处:http://blog.csdn.net/v_JULY_v。 说明:本文分为三部分内容,
- 第三周项目一(1) 建立线性表
- 步进电机的失步和过冲是什么意思
- STL源码分析之vector(三)—其它函数 eraser()、operator[]和operator =
- VMware Workstation Pro安装MS-DOS
- leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal 中后序构造BST
- 数据挖掘
- 判断网络连接状态