我試圖從列爲文件夾的電子郵件地址發送電子郵件。基本上我有一個電子郵件地址分配給它的文件夾。每當有東西到達該電子郵件,它就會進入該文件夾。電子郵件地址不是分配給我的帳戶。我會使用SMTP但我們的公司網絡不允許這樣做。C#Outlook Interop從文件夾發送
如何從C#文件夾的電子郵件中發送電子郵件?
我的代碼設置如下。
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon(Missing.Value, Missing.Value, true, true);
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.Subject = subject;
string html;
html = message;
html = html.Replace("\n","<br/>");
oMsg.HTMLBody = html;
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(to);
//Rest of my closing stuff here.
我很抱歉,我忘了提。我們的網絡不允許我們使用公司的SMTP服務器。我只能通過Outlook發送/接收郵件。 –