C#自动发送outlook群发邮件邮件,怎么在邮件正文中加

C#调用Outlook发送邮件实例源码
C#网络编程
开发语言:C#
实例大小:0.04M
下载次数:
浏览次数:
发布时间:
实例类别:C#网络编程
发 布 人:
所需积分:2
&相关标签:
同类人气实例
实例下载地址
C#调用Outlook发送邮件实例源码
不能下载?内容有错? 点击这里报错
好例子网口号:伸出你的我的手 & 分享!
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
Copyright &
好例子网(www.haolizi.net).All Rights Reserved备案编号:冀ICP备号 石公备号(10)进取,完善,亲历亲为,永无止境。Think it,Build it,Bit by bit !
使用c#给outlook添加任务、发送邮件
c#在使用outlook提供的一些API时,需要将outlook相关的com引用到项目中。 具体方法就是用vs打开工程后,在工程上添加引用,在com选项卡上,选择Microsoft Outlook 12.0 Object Library,如果安装的不是outlook2007,则对应com的版本不一样。注意下面描述的方法是在命令行模式或者winform模式下的,不是web模式下的。 在web模式下使用的方法稍有不同,不在此处讨论。
给outlook添加任务,代码如下:
public static void AddNewTask(string subject, string body, DateTime dueDate, OlImportance importance)
Application outLookApp = new Application();
TaskItem newTask = (TaskItem)outLookApp.CreateItem(OlItemType.olTaskItem);
newTask.Body =
newTask.Subject =
newTask.Importance =
newTask.DueDate = dueD
newTask.Save();
catch(System.Exception e)
}最简单的发送邮件
下面是一个最简单的发送邮件的例子,在该例子中,只能给一个邮箱地址发邮件,而且还不能够添加附件。代码如下:
public static void SimpleSeedMail(string server, string from, string to, string subject, string body, bool isHtml)
MailMessage message = new MailMessage(from, to, subject, body);
message.IsBodyHtml = isH
SmtpClient client = new SmtpClient(server);
client.Credentials = new NetworkCredential("发送者邮箱用户名(即@前面的东东)","发送者邮箱密码");
client.Send(message);
catch (System.Exception e)
}向多人发邮件,并支持发送多个附件
代码如下:
public static void MultiSendEmail(string server, string from, string to, string subject, string body, ArrayList mailAttach, bool isHtml)
MailMessage eMail = new MailMessage();
SmtpClient eClient = new SmtpClient(server);
eClient.Credentials = new NetworkCredential("发送者邮箱用户名(即@前面的东东)", "发送者邮箱密码");
eMail.Subject =
eMail.SubjectEncoding = Encoding.UTF8;
eMail.Body =
eMail.BodyEncoding = Encoding.UTF8;
eMail.From = new MailAddress(from);
string[] arrMailA
#region 添加多个收件人
eMail.To.Clear();
if (!string.IsNullOrEmpty(to))
arrMailAddr = to.Split(';');
foreach (string strTo in arrMailAddr)
if (!string.IsNullOrEmpty(strTo))
eMail.To.Add(strTo);
#endregion
#region 添加多个附件
eMail.Attachments.Clear();
if (mailAttach != null)
for (int i = 0; i & mailAttach.C i++)
if (!string.IsNullOrEmpty(mailAttach[i].ToString()))
eMail.Attachments.Add(new System.Net.Mail.Attachment(mailAttach[i].ToString()));
#endregion
#region 发送邮件
eClient.Send(eMail);
#endregion
catch (System.Exception e)
}异步发送邮件的一个例子。以163的smtp服务器为例。
代码如下:using Susing System.Nusing System.Net.Musing System.Net.Musing System.Tusing System.ComponentMnamespace Examples.SmptExamples.Async{
public class SimpleAsynchronousExample
static bool mailSent = false;
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
String token = (string)e.UserS
if (e.Cancelled)
Console.WriteLine("[{0}] Send canceled.", token);
if (e.Error != null)
Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
Console.WriteLine("Message sent.");
mailSent = true;
public static void Main(string[] args)
SmtpClient client = new SmtpClient("smtp.163.com");
client.Credentials = client.Credentials = new NetworkCredential("发送者邮箱用户名", "发送者邮箱密码");
MailAddress from = new MailAddress("");
MailAddress to = new MailAddress("");
MailMessage message = new MailMessage(from, to);
message.Body = "这是一封测试异步发送邮件的邮件 ";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = "测试异步发邮件";
message.SubjectEncoding = System.Text.Encoding.UTF8;
client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userState = "test message1";
client.SendAsync(message, userState);
Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
string answer = Console.ReadLine();
if (answer.StartsWith("c") && mailSent == false)
client.SendAsyncCancel();
message.Dispose();
Console.WriteLine("Goodbye.");
Console.ReadLine();
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!C#瀹炵幇outlook鑷?姩绛惧悕 - 閭?欢鏈嶅姟 -
杩愮淮缃

我要回帖

更多关于 outlook邮件正文空白 的文章

 

随机推荐