Link to home
Start Free TrialLog in
Avatar of phil301
phil301

asked on

80070005 error in acceses

I am receiving the following error when attempting to send an E-mail through outlook using the web server. I know it has something to do with the COM security issues. Can someone please help me with the procedure for installing the COM on the webserver and setting the security policy. Thanks in advance.

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.

Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 709:        ' Create an Outlook application.
Line 710:        Dim oApp As Outlook._Application
Line 711:        oApp = New Outlook.Application()
Line 712:
Line 713:        ' Create a new MailItem.
 


My code is as follows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Create an Outlook application.
        Dim oApp As Outlook._Application
        oApp = New Outlook.Application()

        ' Create a new MailItem.
        Dim oMsg As Outlook._MailItem
        oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
        oMsg.Subject = "Send Attachment Using OOM in Visual Basic .NET"
        oMsg.Body = "Hello World" & vbCr & vbCr

        ' TODO: Replace with a valid e-mail address.
        oMsg.To = "philip.hunnicutt@baesystems.com"

        ' Add an attachment
        ' TODO: Replace with a valid attachment path.
        Dim sSource As String = "C:\Temp\Hello.txt"
        ' TODO: Replace with attachment name
        Dim sDisplayName As String = "Hello.txt"

        Dim sBodyLen As String = oMsg.Body.Length
        'Dim oAttachs As Outlook.Attachments = oMsg.Attachments
        'Dim oAttach As Outlook.Attachment
        'oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)

        ' Send
        oMsg.Send()

        ' Clean up
        oApp = Nothing
        oMsg = Nothing
        'oAttach = Nothing
        'oAttachs = Nothing

    End Sub
ASKER CERTIFIED SOLUTION
Avatar of vbandaru
vbandaru

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phil301
phil301

ASKER

How do you use "System.Web..Mail"?

I tryed to use

Imports System.Web.Mail and it does not recognise it.
Avatar of phil301

ASKER

Ok, I managed to connect to the server and get it to send mail through the ASP.NET page. However, the mail is never getting delivered. I think it has something to do with the setttings on the default smtp server on the webserver. Anyone have any insight on how to set this up. I just installed the mail services on Windows Server 2003.
You may get a better response by posting your question at https://www.experts-exchange.com/Networking/Email_Groupware/Exchange_Server/.

If you feel that I assisted you please accept the answer. Thanks
Avatar of phil301

ASKER

Thanks, I will repost the question there.