编程实现sharepoint工作流中的发送邮件功能
2013-07-26 12:45
344 查看
如果你要在sharepoint工作流中实现发送邮件功能,需要
1.在管理中心设置你的smtp服务器地址,发件人信息
2.在VS2005开发的工作流中编写如下代码
using Microsoft.SharePoint.Utilities;
SPUtility.SendEmail(SPContext.Current.Web, false, false,
"to-address@mail.com", "E-mail title",
"E-mail body");
当然你也可以使用普通的.net类来发邮件(System.Net.Mail namespace)
但此方法的好处是:
你的代码中不用再进行对SMTP服务器进行配置的代码了。
用System.Net.Mail命名空间发邮件的方法是:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Net.Mail;
namespace MailSender
{
public partial class MailUtil: Page
{
protected void Page_Load(object sender, EventArgs e)
{
//邮件内容
MailMessage mail = new MailMessage("inter@18inter.com", "inter@18inter.com", "测试", "正文文");
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
mail.ReplyTo = new MailAddress("vicky@18inter.com","vicky"); //邮件回复地址
//mail.Bcc.Add("itwind@163.com,478779122@qq.com"); //密抄
//发送邮件
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.sohu.com";
smtp.Credentials = new NetworkCredential("xxxxx@sohu.com", "*****"); //发邮件的EMIAL和密码
//smtp.EnableSsl = true; //Gmail时使用
try
{
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
本文出自 “宋超技术博客” 博客,请务必保留此出处http://soungcha.blog.51cto.com/1075631/1258025
1.在管理中心设置你的smtp服务器地址,发件人信息
2.在VS2005开发的工作流中编写如下代码
using Microsoft.SharePoint.Utilities;
SPUtility.SendEmail(SPContext.Current.Web, false, false,
"to-address@mail.com", "E-mail title",
"E-mail body");
当然你也可以使用普通的.net类来发邮件(System.Net.Mail namespace)
但此方法的好处是:
你的代码中不用再进行对SMTP服务器进行配置的代码了。
用System.Net.Mail命名空间发邮件的方法是:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Net.Mail;
namespace MailSender
{
public partial class MailUtil: Page
{
protected void Page_Load(object sender, EventArgs e)
{
//邮件内容
MailMessage mail = new MailMessage("inter@18inter.com", "inter@18inter.com", "测试", "正文文");
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
mail.ReplyTo = new MailAddress("vicky@18inter.com","vicky"); //邮件回复地址
//mail.Bcc.Add("itwind@163.com,478779122@qq.com"); //密抄
//发送邮件
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.sohu.com";
smtp.Credentials = new NetworkCredential("xxxxx@sohu.com", "*****"); //发邮件的EMIAL和密码
//smtp.EnableSsl = true; //Gmail时使用
try
{
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
本文出自 “宋超技术博客” 博客,请务必保留此出处http://soungcha.blog.51cto.com/1075631/1258025
相关文章推荐
- 编程实现sharepoint工作流中的发送邮件功能(转载)
- 强大的java编程实现邮件发送功能,支持内容,上传多个图片和多个附件
- Spring实现邮件发送功能
- JavaWeb中使用JavaMail实现发送邮件功能实例详解
- java实现发送邮件功能
- [导入]分布式编程->Remoting的一个代码示例(借助Remoting实现发送信息功能)
- 实现 一个邮件发送功能
- 使用java实现发送邮件功能
- 简单QQ邮件发送功能的实现
- php smtp实现发送邮件功能
- SpringBoot中发送QQ邮件功能的实现代码
- thinkphp5中使用phpmailer实现发送邮件功能
- springMVC项目中实现发送邮件功能
- python实现微信发送邮件关闭电脑功能
- Android开发之发送邮件功能的实现(源代码分享)
- thinkphp实现发送邮件密码找回功能实例
- SQL Server 2008 通过配置数据库邮件实现发送邮件功能
- Python3实现发送QQ邮件功能(html)
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- Java的Spring框架中实现发送邮件功能的核心代码示例