I have an asp.net application in c# running IIS 7 on Windows 7.

An email is sent out when a certain event occurs, driven by the client user.

The code is as below: I am using Outlook Interop instead of Exchange SMTP server since the smtpClient is being blocked by McAfee and I am not allowed to change McAfee settings.

When trying to send an email, following error is thrown: System.Runtime.InteropServices.COMException (0x80030005): You don't have appropriate permission to perform this operation. at Microsoft.Office.Interop.Outlook.ApplicationClass.CreateItem(OlItemType ItemType) at in <.cs file name>.

IIS application pool is using NetworkService as ProcessModel identity. I also checked DCOMCNFG and it has Network service as an authorized user with appropriate permissions.

How can I fix this? Any help would be greatly appreciated. Thanks in advance.

    using outlook = Microsoft.Office.Interop.Outlook;

    outlook.Application olkApp1 = new outlook.Application();

            outlook.MailItem olkMail1 = (outlook.MailItem)olkApp1.CreateItem(outlook.OlItemType.olMailItem);
            outlook.Accounts accounts = olkApp1.Session.Accounts;
            foreach (outlook.Account account in accounts)
                if (account.SmtpAddress == "")
                    olkMail1.To = toEmail;
                    if (ccEmail != null)
                        olkMail1.CC = ccEmail;
                    olkMail1.Subject = subjEmail;
                    olkMail1.Body = bodyEmail;
                    //olkMail1.Attachments.Add(filePath, outlook.OlAttachmentType.olByValue, 1, "attachment");
                    olkMail1.SendUsingAccount = account;

Related posts

Recent Viewed