工作中需要通过outlook发送回执邮件到指定用户组,封装代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;
using OutlookApi.Utils;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Diagnostics;
namespace Common
{
public class MailHelper
{
public static bool SendMail(string Subject, string Content)
{
bool res = false;
try
{
//string curDate = DateTime.Now.ToString("yyyyMMdd"); //当前日期
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
DataTable dt = new DataTable();
dt = WebSrv_CL_Auto.GetMailList();
foreach (DataRow row in dt.Rows)
{
msg.To.Add(row["收件人地址字段"].ToString());
}
msg.To.Add("[email protected]");
msg.From = new MailAddr