6

I am getting this error when I try to send via the local server

CDO.Message.1 error '80070005' 

Access is denied. 

/mail.asp, line xxx 

Here is the code I am using

  MailBodyText = "TEST"

  Set objNewMail = CreateObject("CDO.Message")
  objNewMail.To =  sSendTo
  objNewMail.From = "webmaster@EXAMPLE.com"
  objNewMail.Cc = "webmaster@EXAMPLE.com"
  objNewMail.Subject =  "Information Request & Feedback"
  objNewMail.HTMLBody = "The following information was sent from " & sEmail & ":" & "<br>" & CHR(13) & MailBodyText & "<br>copies of this mail we sent to :"& sSendTo
  objNewMail.Send

  Set objNewMail = Nothing 

It looks like it is a permission error at the ISSUR doesn't have write permission to write to the mailroot/pickup folder.

But we have checked that and the services account that this site is using seems to have the rights.

Question is this error always a file permission error?

Question how to know / set the location that CDO is using? So we can confirm the permissions

What else should look at to fix this?

Taryn East
  • 27,486
  • 9
  • 86
  • 108
Pbearne
  • 1,025
  • 3
  • 12
  • 25

3 Answers3

5

Use the .configuration property which allows for authentication and other fine tuning..

examples at : http://www.paulsadowski.com/wsh/cdo.htm

update

The .configuration property allows to set the pickup directory (as you request)

objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
objNewMail.Configuration.Fields.Update
objNewMail.Send
Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
  • thanks for this but I am not trying to send the mail to a remote server just get it to work on the local box. – Pbearne Jun 07 '10 at 19:44
  • @Pbearne, you can set the pickup directory through the `.configuration` property (*updated answer*) – Gabriele Petrioli Jun 07 '10 at 21:04
  • Thanks for the extra code example it work on the dev server I hate having to put paths into code. but I can live with it – Pbearne Jun 09 '10 at 13:03
4

IF YOU DON'T WANT TO CHANGE YOUR CODE

Grant IIS_IUSRS group write access to c:\inetpub\mailroot\Pickup folder or whatever is your pickup dir.

It must be IIS_IUSRS Group, not the IUSR User (you got it mispelled probably).

I was getting this error after performing steps specified in option 3 at blog.msdn.com

I didn't have to change the ASP code. Your code works fine on my server.

Combinatix
  • 1,186
  • 3
  • 12
  • 24
  • 2
    This should be the accepted answer as this is the cause of the `Access Denied` message. The `IIS_IUSRS` group contains on the `ApplicationPoolIdentity` accounts for each site on the server so if your configuring this at a server level this approach works great. Just remember that your pickup folder will need to give `IIS_IUSRS` *at least* `modify` permission or you will continue to get the error. – user692942 Jul 18 '14 at 09:02
  • However the linked article is for another error (`Error:CDO.Message.1 (0x80040220) The "SendUsing" configuration value is invalid on IIS 7.5`) and in this case adding permissions to the `IIS metabase` will do **nothing** the issue is folder permissions for the pickup folder. – user692942 Jul 18 '14 at 09:21
0

I am migrating some old classic asp sites to a new (windows 2008R2) server and I had "exactly" the same problem (well at least the same error and basically the same code). The solution presented by Gaby:

objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"

did not work for me, i still had the same error.

After some searching i found this suggestion:

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 

(do NOT set the smtpserverpickupdirectory)

Now it works fine.

By the way if you need to set up the necessary SMTP service on Windows 2008 server (IIS7), I found this blog extremely helpfull.

UPDATE:

According to microsoft sendusing = 1 uses the SMTP server and sendusing 2 uses Outlook Express, I've looked on the server, and there doesn't seem to be outlookexpress or windows mail installed, still this setting workes for me. If anyone could explain that I'm curious to know.

Michiel
  • 4,160
  • 3
  • 30
  • 42