以编程方式将电子邮件发送到Outlook 2010 [英] Programmatically send email to outlook 2010

查看:119
本文介绍了以编程方式将电子邮件发送到Outlook 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下代码向Outlook帐户发送电子邮件..

I''m trying to send emails to an outlook accounts witn the folowing code..

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem email = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
email.Recipients.Add("hari.prasad@fnu.ac.fj");
email.Subject = "TestSubject";
email.Body = "TestBody";
((Outlook.MailItem)email).Send();


消息确实得到发送,但在接收者端却发出警告..
一个程序正试图访问存储在Outlook中的电子邮件信息.如果这是意外发生,请单击deny ... n,依此类推..

现在,一旦我允许该操作,则仅接收到该消息..N这就是我不想要的...是否有更好的方法来执行此操作,或者如何进行改进以避免此类消息.


The message does get send but at the receivers end im getting a waring say..
a programm is trying to access e-mail infromation stored in Outlook.If this is unexpected,click deny......n so on..

Now once i allow this then only the message is receive..N this is what i dont want...Is there a better way of doing this or how can i inprove to avoid this kind of message.

推荐答案

您为什么要这样做.可接受的方式如下:
Why are you doing it that way. The accepted way would be like this:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("emailAddress@yourPlace.com");
message.Subject = "Put a subject here";
message.From = new System.Net.Mail.MailAddress("emailFromAddress@someplace.com");
message.Body = "Put your message here";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Send(message);


这篇关于以编程方式将电子邮件发送到Outlook 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆