We help IT Professionals succeed at work.

Access Denied error when using CDOSys to send messages in ASP

ashraga
ashraga asked
on
3,705 Views
Last Modified: 2007-12-19
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.
Comment
Watch Question

what is on line 91 or send.asp?

Author

Commented:
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

Author

Commented:
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.
Alan WarrenApplications Developer

Commented:
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    
%>

Author

Commented:
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!
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.