2013-05-15 69 views
1

Outlook郵件集成我有窗口的應用程序在我的系統上運行的,我可以在任何地方通過發送 郵件,但我想我的應用程序整合的前景。與.NET Desktop應用程序

1.Sent郵件應該是在顯示後市發送郵件文件夾。 2.In情況下,郵件發送失敗是它應該在Outlook的發件箱文件夾

+0

根據您的項目,您可能需要考慮構建一個Outlook AddIn?請參閱:http://msdn.microsoft.com/en-us/library/cc668191.aspx –

回答

1

經過下面的代碼顯示:

Outlook.Application oApp = new Outlook.Application(); 

if (this.listViewContacts.SelectedItems != null && 
this.listViewContacts.SelectedItems.Count > 0) 
{ 
Outlook.ContactItem oRecip = (Outlook.ContactItem) 
(this.listViewContacts.SelectedItems[0].Tag); 

Outlook.MailItem email = (Outlook.MailItem) 
(oApp.CreateItem(Outlook.OlItemType.olMailItem)); 
email.Recipients.Add(oRecip.Email1Address); 
email.Subject = "Just wanted to say..."; 
email.Body = "Have a great day!"; 

if (MessageBox.Show(
"Are you sure you want to send a good day message to " + 
oRecip.Email1DisplayName + "?", "Send?", 
MessageBoxButtons.OKCancel) 
== DialogResult.OK) 
{ 
try 
{ 
((Outlook.MailItem)email).Send(); 
MessageBox.Show("Email sent successfully.", "Sent"); 
} 
catch (Exception ex) 
{ 
MessageBox.Show("Email failed: " + ex.Message, 
"Failed Send"); 
} 
} 

oRecip = null; 
email = null; 
} 

全球化志願服務青年鏈接:

http://www.codeguru.com/csharp/csharp/cs_misc/e-mail/article.php/c14293/Microsoft-Outlook-Integration-with-CNET.htm#page-2

在這個鏈接中給出了一步一步的實施和解釋。

希望它有幫助。

+0

感謝它的工作,但花費更多時間發送郵件 – user1920832