




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Email发送代码1. C#代码发送类using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Net.Mail;using System.Web.Configuration;u
2、sing System.Collections.Generic;namespace WBIS.Base.Fun / <summary> / funSentEmail 的摘要描述 / </summary> public class funSentEmail public static string Error; / <summary> / / </summary> / <param name="FromEmail">发送人</param> / <param name="ToEmail&qu
3、ot;>接收人</param> / <param name="Subject">主题</param> / <param name="Body">内容</param> / <param name="host">主机或服务器</param> / <param name="port">端口</param> / <returns></returns> public static bool
4、 SendEmail(string ToEmail, string Subject, string Body) bool Success = false; try string FromEmail = Constant.strEmaiFrom; string host = Constant.strMailserver; int port = CPort; System.Net.Mail.SmtpClient client; if (port != 0) client = new SmtpClient(host, port); else client = new SmtpC
5、lient(host); /client.Credentials = new System.Net.NetworkCredential("Ki", "123456"); /string inceptMail = WebConfigurationManager.AppSettings"ek_InceptMail".ToString(); /MailMessage message = new MailMessage(); /message.Bcc.Add(inceptMail); /message.From = new MailAddre
6、ss(FromEmail); /message.To.Add(ToEmail); MailAddress from = new MailAddress(FromEmail); MailAddress to = new MailAddress(ToEmail); MailMessage message = new MailMessage(from, to); message.Subject = Subject; message.Body = Body; message.IsBodyHtml = true; client.Send(message); Success = true; catch (
7、Exception ex) Error = ex.Message; Success = false; return Success; / <summary> / 发送email / </summary> / <param name="FromEmail">发送人</param> / <param name="ToEmail">接收人</param> / <param name="Subject">主题</param> / <param
8、 name="Body">内容</param> / <param name="host">主机或服务器</param> / <param name="port">端口</param> / <param name="strFiler">附件的地址</param> / <returns></returns> public static bool SendEmail(string ToEmail, strin
9、g Subject, string Body, string strFiler) bool Success = false; if (!System.IO.File.Exists(strFiler) return false; try string FromEmail = Constant.strEmaiFrom; string host = Constant.strMailserver; int port = CPort; System.Net.Mail.SmtpClient client; if (port != 0) client = new SmtpClient(
10、host, port); else client = new SmtpClient(host); MailAddress from = new MailAddress(FromEmail); MailAddress to = new MailAddress(ToEmail); MailMessage message = new MailMessage(from, to); message.Subject = Subject; message.Body = Body; message.IsBodyHtml = true; Attachment data = new Attachment(strF
11、iler); message.Attachments.Add(data); client.Send(message); Success = true; catch (Exception ex) Error = ex.Message; Success = false; return Success; 2. asp代码通过JMAIL进行发送如果服务器没有注册jmail,需要注册jmail:将jamil.dll组件复制到系统所在的磁盘的system32活页夹下(如:c:winntsystem32),然后执行“开始”->“运行”命令,在弹出的“运行”对话框中输入regsvr32 jmail.dl
12、l<%On Error Resume Next Set jmail = Server.CreateObject("JMAIL.SMTPMail") '建立JMAIL对象if err then err.clear Response.Write("组件检测失败!") jmail.close() Set jmail=nothingelse jmail.logging = true '使用日志 jmail.Charset = "big5" '字体 jmail.ContentType = "text/ht
13、ml" '文件的格式 jmail.ServerAddress = strServer '发送的服务器 jmail.AddRecipient strTo '收件人 jmail.SenderName = " " '收件的姓名 jmail.Sender = strFrom '发送的邮件 jmail.Priority = 1 '1 最快,5 最慢, 3 默认 jmail.Subject = "Mail Subject" '主题 jmail.Body = "Mail Body"
14、'内容 'jmail.AddRecipientBCC strServerUN '密件收件人的地址 'jmail.AddRecipientCC strServerPW '邮件件抄送者的地址 jmail.Execute() '执行发送 jmail.Close '关闭对象Set jmail=nothingif err thenresponse.Write Err.Descriptionerr.clearend if end if%>3. asp上传控件的使用如果服务器没有注册AspUpload上传组件,需要注册AspUpload:安装as
15、pupload.exe,安装完成后,在安装路径下找AspUploadBin把AspUpload.dll复制到系统所在的磁盘的system32活页夹下(如:c:winntsystem32),然后执行“开始”->“运行”命令,在弹出的“运行”对话框中输入regsvr32 AspUpload.dll需要设定form提交的属性 ENCTYPE="multipart/form-data"如:<form action="maintain_meteor_up.asp" ENCTYPE="multipart/form-data" name="form1" method="post" onsubmit="return checkform();">maintain_meteor_up.asp页面是进行上传的动作在maintain_meteor_up.asp页的主要代码:Set Upload = Server.CreateObject("Persits.Upload.1")Upload.SetMaxSize 50
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中国环保袋行业市场分析及投资价值评估前景预测报告
- 2025内蒙古赤峰穆香源肉类食品有限公司招聘考前自测高频考点模拟试题附答案详解(完整版)
- 2025福建泉州市永春县部分公办学校专项招聘编制内新任教师23人(二)考前自测高频考点模拟试题附答案详解(考试直接用)
- 2025年石嘴山市科技馆公开招聘编外聘用人员模拟试卷及一套答案详解
- 2025年4月广东广州市天河区珠江新城猎德幼儿园第二次编外教辅人员招聘1人模拟试卷及参考答案详解1套
- 2025年芜湖宜居投资(集团)有限公司招聘10人模拟试卷附答案详解(考试直接用)
- 2025年城步苗族自治县事业单位公开选调工作人员考前自测高频考点模拟试题及一套答案详解
- 2025内蒙古牙克石五九煤炭(集团)有限责任公司校园招聘26人考前自测高频考点模拟试题及1套完整答案详解
- 2025北京首都师范大学实验小学招聘2人考前自测高频考点模拟试题及参考答案详解1套
- 2025黑龙江绥化市明水县人民医院招聘中医医生模拟试卷有答案详解
- 医院培训课件:《S/D 比值临床价值》
- 《湖南民居特色》课件
- 中国老年患者术后谵妄防治专家共识
- 2025年度火锅店合伙人合作协议书:特色火锅底料配方保密协议
- 岗位化验员述职报告
- 2023年价格鉴证师考试《价格鉴证案例分析》试题真题及答案二
- 2025年中信保诚人寿保险有限公司招聘笔试参考题库含答案解析
- 我的家乡沧州
- 两人合伙经营网吧协议
- 【课件】纪念长津湖吾辈当自强!课件 -2024年12.24纪念抗美援朝主题班会
- 2023-2024届高考语文复习小说专题训练(含答案)-李存葆《高山下的花环》
评论
0/150
提交评论