阅读:5870
回复:9
|
[已解决]需要一段后台写的发邮件的代码,谢谢!
需要一段后台写的发邮件的代码,谢谢!
|
1楼#
发布于:2016-09-19 10:47
protected void btnSend_Click(object sender, EventArgs e)
{ OThinker.H3.Notification.Notification n = new OThinker.H3.Notification.Notification( OThinker.H3.Notification.NotifyType.Email, null, null, "741806694@qq.com", null, 0, null, this.PortalResource.GetString("Settings_TestEmail"), string.Format(this.PortalResource.GetString("Settings_TestEmailContent"), OThinker.H3.Configs.ProductInfo.ProductName), null); OThinker.H3.WorkSheet.AppUtility.Engine.Notifier.Notify(n); } |
|
|
2楼#
发布于:2016-09-19 10:52
/// <summary>
/// 发送电子邮件 /// </summary> /// <param name="Address">邮件地址</param> /// <param name="Subject">邮件标题</param> /// <param name="Body">邮件内容</param> public void SendEmail(string Address, string Subject, string Body) { string smtp = "服务器"; if (!string.IsNullOrEmpty(smtp)) { string from = "系统管理员"; string userName = "coli_workflow@cohl.com";// from;// @"coli\coli_workflow"; string password = "你的密码"; try { // 发送该邮件 System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(smtp); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(userName, password); client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; client.EnableSsl = false; client.Port = 25;// VesselCustomSetting.GetValue<int>(this.GetSettingValue(VesselCustomSetting.Setting_SmtpPort), 25); Encoding subjectEncoding = null; // 默认值是UTF8 subjectEncoding = System.Text.Encoding.UTF8; Encoding bodyEncoding = subjectEncoding; this.SendMailBySmtp(client, userName, from, subjectEncoding, bodyEncoding, Address, Subject, Body); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } |
|
|
4楼#
发布于:2016-09-20 09:48
|
|
5楼#
发布于:2016-09-20 10:54
|
|
|
6楼#
发布于:2016-09-22 14:58
楼主,想请问问题是否得到解决,用的那个方案?
|
|
|
7楼#
发布于:2016-09-23 09:03
|
|
9楼#
发布于:2016-09-23 09:23
|
|
|