文章目录[隐藏]
关键词:c#,outlook发邮件
c#调用Outlook发送邮件
using Outlook = Microsoft.Office.Interop.Outlook; using (Outlook.Application olApp = new Outlook.Application()) { using (Outlook.MailItem mailItem = (Outlook.MailItem)olApp.CreateItem(Outlook.OlItemType.olMailItem)) { mailItem.To = "[email protected]"; mailItem.Subject = "A test"; mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML; mailItem.HTMLBody = "Hello world"; //now attached the file int attachPos = (int)mailItem.Body.Length + 1; int attachType = (int)Outlook.OlAttachmentType.olByValue; mailItem.Attachments.Add(@"C:\\hello.txt", attachType, attachPos, attachName); ((Outlook._MailItem)mailItem).Send(); MessageBox.Show("Mail has been sent successfully!"); } }
来源搞代码网《c#调用Outlook发送邮件》http://www.gaodaima.com/68575.html