1. 开启SMTP服务
2. 管理中心配置传出邮件
3. 源代码action中填写 SPUtility.SendEmail(SPContext.Current.Web, false, false, "收件人邮箱","标题", "内容");
4.点击全选按钮发送邮件:
string checkedItem = context.Request["checkedItem"];
string[] chItem = checkedItem.Split(',');//','号分开的对象
foreach (string item in chItem)//遍历
{
string userSql = server.ExecuteScalar("select StaffAccountID from sel where ID in (" + item + ") ") + "";//获取数据库中选中行的StaffAccountID
string userEmail = GetEmailByAccountName(userSql);//根据域账号的StaffAccountID获取邮箱
SPUtility.SendEmail(SPContext.Current.Web, false, false, userEmail, "测试, "测试");//发送邮件
}