使用Outlook的发送电子邮件从C#
我想写应用程序谁使用Outlook发送电子邮件,我发现this链接。 我尝试了这一点,它对我来说很完美,但是我唯一想念的地方就是附加文件到邮件的选项,有可能吗?使用Outlook的发送电子邮件从C#
更好地使用MailMessage。
有一个关于如何使用安装在这里使用它的一个示例(向下滚动到“实例”): http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
不仅你会得到一个管理框架,用于发送邮件,也无论谁运行的代码将不再需要展望安装并运行。
字符串服务器意味着我的SMTP服务器? – 2012-04-08 15:46:23
发送电子邮件后,我看到wireshark smtp数据包但电子邮件没有到达 – 2012-04-08 15:58:58
它现在好谢谢 – 2012-04-08 16:55:11
如果你坚持的前景出于某种原因,试试这个:
using Outlook = Microsoft.Office.Interop.Outlook;
int pos = (int)email.Body.Length + 1;
int attType = (int)Outlook.OlAttachmentType.olByValue;
email.Attachments.Add("file.txt", attType, pos, "File description.");
其中:
Outlook.MailItem email = (Outlook.MailItem)_outlookAppInstance.CreateItem(Outlook.OlItemType.olMailItem);
可怕的事情要做。努力+1! – Robino 2014-05-07 14:36:06
哈哈,对吧?谢谢。 – nicholeous 2014-06-06 20:14:22
是的,它是。你有没有尝试过?你有什么尝试?它有用吗? – 2012-04-08 15:09:02
我没找到怎么办 – 2012-04-08 15:11:57
你有什么理由在MailMessage上专门使用Outlook interop吗? – Svarog 2012-04-08 15:22:26