Link to home
Start Free TrialLog in
Avatar of ashraga
ashraga

asked on

Access Denied error when using CDOSys to send messages in ASP

Hello,

I've recently upgraded my servers to Win 2003 so I'm trying to migrate my ASP code to begin using CDOSYS instead of CDONTS to send Mail messages. The server is used as a web server (IIS) and as a Mail server (Exchange 2003).

I'm getting a strage error on the line that does the actual objMail.Send():

CDO.Message.1 error '80070005'
Access is denied.
/site/send.asp, line 91

I've tried everything on the web to fix this. The IUSR and IWAM accounts both have full access to the mailroot folder in inetpub. They also have full access to Exchange's Mailroot folder (in case that's where IIS is sending messages from). I've even added those 2 users to the Administrators group, and I'm still getting the same error.

Any help would be greatly appreciated. Thanks,

Avishai Shraga
Avix Solutions, Inc.
Avatar of chenkewind
chenkewind
Flag of United States of America image

what is on line 91 or send.asp?
Avatar of ashraga
ashraga

ASKER

Here is a snippet

dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.From = strFrom
objMail.To = strTo
objMail.Subject = strSubject
objMail.TextBody = strBody
objMail.Send
set objMail = nothing

Line 91 is the objMail.Send line

Thanks
Avatar of ashraga

ASKER

Here is a snippet

dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.From = strFrom
objMail.To = strTo
objMail.Subject = strSubject
objMail.TextBody = strBody
objMail.Send
set objMail = nothing

Line 91 is the objMail.Send line

Thanks
Well, there's an article that seems to help use CDO, but only possibly will help with the permissions errors:
http://www.aspfaq.com/show.asp?id=2026

Also, just to verify, the IUSER account needs rights to send mail using Exchange and CDO.
Also, make sure all the service packs are installed to the exchange server.

Another thing is that if your exchange server is a domain controller, it might need a little more administration to work.
I've read somewhere that you have to change is the "Log On Locally" policy under "Domain
Controller Security Policy". There you must add "Domain Users".

And from that link I offered above, try using the set objMail.configuration = ... line.
That might be necessary.

Cheers.
Hi ashraga,

You may need to establish a cdo.configururation

Try this, if no smtp server is passed eg "" then will try to send using port, you can either use your smtp server or your isp's smtp server, they should support mail forwarding for you. eg... smtp.yahoo.com

Alan Warren


<%
If SendEmail("smtp.yourserver.com") Then
  response.write("mail sent")
End If
%>

<%
Private Function SendEmail(SMTPServer)

  Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
  Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
  Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing
'hmm!
Const cdoSMTPPickup = "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"

  Const cdoAnonymous = 0
  Const cdoSendUsingPickup = 1
  Const cdoSendUsingPort = 2
     
  Dim oMessage
  Dim oConfiguration

  SendEmail = False
     
  Set oConfiguration = Server.CreateObject("CDO.Configuration")
  With oConfiguration.Fields
    .Item(cdoSMTPAuthenticate) = cdoAnonymous
    .Item(cdoSMTPServer) = SMTPServer
    If Trim(SMTPServer) = "" Then
      .Item(cdoSendUsingMethod) = cdoSendUsingPickup
'hmm!
.Item(cdoSMTPPickup) = "C:\inetpub\mailroot\pickup"
    Else
      .Item(cdoSendUsingMethod) = cdoSendUsingPort
    End If
    .Update
  End With

  Set oMessage = Server.CreateObject("CDO.Message")

  With oMessage
    Set .Configuration = oConfiguration
        .From     = "You@Your.com"
        .To       = "Me@My.com"
        .Subject  = "The subject"
        .TextBody = "The body"
        .Send
  End With

  Set oMessage = Nothing
  Set oConfiguration = Nothing

  If Err.Number = 0 Then
    SendEmail = True
  End If

End Function    
%>
Avatar of ashraga

ASKER

I fixed the problem myself. You need to change the Application Pool in IIS for this web site to use the Exchange Application Pool instead of the default IIS pool...

thanks for everyone's help!
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

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