0

I received the following error when I tried to send email from web application although it was working good before , Do you have any idea about that ? and it working in the debug mode of visual studio but is not working through the IIS right now.

“Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.”

As per my understanding this error is related to access denied of IIS to outlook object but i try to find solution for that in google : the solution is to make permission to IIS-USRs account for the outlook but I don’t know how to do that So, i try to find MS-OUTLOOK on dcom to add IIS-USRS but i can't find it could you tell me the exact name of outlook on DCOM.

My Code as below

        Dim ol As New Outlook.Application()
        Dim ns As Outlook.NameSpace
        Try
            Dim fdMail As Outlook.MAPIFolder
            ns = ol.GetNamespace(MAPI)
            ns.Logon(, , True, True)


            'creating a new MailItem object
            Dim newMail As Outlook.MailItem
            'gets defaultfolder for my Outlook Outbox
            fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
            'assign values to the newMail MailItem
            newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
            newMail.Subject = RecordtypeDropDownList.Text +  Notification
            newMail.Body = You got  + RecordtypeDropDownList.Text +   for  + CategoryDropdownList.Text

            'newMail.To = EmaildropDownlistEM.Text ' we will pass the email from record missbonus point table in the final stage

            newMail.To = Mid(EmaildropDownlistEM.Text, (EmaildropDownlistEM.Text.IndexOf(, )) + 2, 10) + . + Left(EmaildropDownlistEM.Text, EmaildropDownlistEM.Text.IndexOf(, ))


            newMail.CC = xxxxxxxxx

            newMail.SaveSentMessageFolder = fdMail
            newMail.Send()
        Catch ex As Exception
            Throw ex
        End Try
  • 2
    You should not really be using Outlook Automation to send email from an ASP.Net environment, what's wrong with the frameworks email classes? – Alex K. Nov 27 '15 at 13:43
  • thanks for your reply,So what your suggestion if i have outlook account on the same server of IIS and i want to let it to send emails for asp.net app – Ahmed kamal Nov 27 '15 at 14:05
  • Do you need outlook for some reason? http://stackoverflow.com/questions/18326738/how-to-send-email-in-asp-net-c-sharp – Alex K. Nov 27 '15 at 14:06
  • yes,1- because was very simple to configure it in visualbasic 2-when i tried the gmail i found some times is not working if the internet provider closes the gmail port will not working – Ahmed kamal Nov 27 '15 at 14:23
  • Can you show your code please? What assemblies or APIs are you using? – Eric Legault Nov 27 '15 at 16:36
  • thanks for your help my code as above – Ahmed kamal Nov 27 '15 at 17:03
  • import System.Net.Mail import System.Net import Outlook = Microsoft.Office.Interop.Outlook i think you need that – Ahmed kamal Nov 27 '15 at 17:09

1 Answers1

0

You cannot use Outlook (or any other Office app) in a service (such as IIS). In case of Exchange, you can use EWS. In all other cases, using straight SMTP is probably the best solution.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78