IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Fix Permission Denied Error 800a0046

If you still use CDONTS object in your ASP page and run into this kind of error:

Microsoft VBScript runtime error '800a0046'

Permission denied

/path/filename.asp, line 4

Then when you open the file, you see something like this.

Set oCDOMail = Server.CreateObject("CDONTS.NewMail")

oCDOMail.Importance = 1
oCDOMail.Send

Just by reading the error message, you can probably guess that this error occurs usually because the anonymous user account is not granted a Modify permission to the mailroot folder and it can be easily resolved by following these steps:

  1. Open Windows Explorer and locate the mailroot folder. The default should be C:\inetpub\mailroot, but this may be moved by your system administrator.
  2. Right-click the mailroot folder, then click Properties.
  3. On the Security tab, click on the Edit button.
  4. Click Add.
  5. Add IUSR_ and IWAM_ (separated by a semi-colon). Make sure the location is your desktop, not your domain name. Click Check Names, then OK.
  6. Give Modify permission for each of the account added previously. Click OK.
  7. Click OK to close the dialog box.

This time your asp page should render without any issues.

As in our exprience, there will be time when you upgrade a very old system, when you try to grant these permissions, you’ll see some garbled error message and it still doesn’t resolve the problem. When all else fails, and it may be easier and faster to replace the code using CDO (cdosys.dll).

August 20, 2015 Filed Under: How To Tagged With: Cdonts Dll, Classic ASP, Windows 2012, Windows Server

How to Replace CDONTS with CDOSYS on Classic ASP Pages

Replacing CDONTS with CDOSYS, while can be time consuming for a large classic ASP application, is actually very easy to do. Here’s a simple example of what need to be changed at a minimum:

  1. Set oCDOMail = Server.CreateObject(“CDONTS.NewMail”) to:
    Set oCDOMail = Server.CreateObject(“CDO.Message”)
  2. Remove BodyFormat property, oCDOMail.BodyFormat = 0 since it’s unnecessary.
  3. Replace MailFormat property oCDOMail.MailFormat = 0 with MimeFormatted property oCDOMail.MimeFormatted = True.
  4. You may also want to add Charset property.
    oCDOMail.BodyPart.Charset = “utf-8”
  5. Replace oCDOMail.Body with oCDOMail.HTMLBody.
  6. Replace Importance property oCDOMail.Importance = 1 with oCDOMail.Fields(“urn:schemas:mailheader:priority”).Value = 1

The typical page composition to send email using either object can be seen below:

CDONTS

<%
  Dim oCDOMail
               
  Set oCDOMail = Server.CreateObject("CDONTS.NewMail")
               
  oCDOMail.From = ...
  oCDOMail.To = ...

  oCDOMail.Subject = "CDONTS email"
  oCDOMail.BodyFormat = 0
  oCDOMail.MailFormat = 0
  oCDOMail.Importance = 1
               
  oCDOMail.Body = "<html><body><p>This is a test.</p></body></html>"
               
  oCDOMail.Send
               
  Set oCDOMail = Nothing
%>

CDO

<%
  Dim oCDOMail
               
  Set oCDOMail = Server.CreateObject("CDO.Message")
               
  oCDOMail.From = ...
  oCDOMail.To = ...
  oCDOMail.Subject = "CDO email"
  oCDOMail.BodyPart.Charset = "utf-8"
  oCDOMail.MimeFormatted = True
  oCDOMail.Fields("urn:schemas:mailheader:priority").Value = 1
               
  oCDOMail.HTMLBody = "<html><body><p>This is a test.</p></body></html>"
               
  oCDOMail.Send
               
  Set oCDOMail = Nothing
%>

And here’s the two pages compared side-by-side:
CDONTS vs CDOsys Sendmail ASP Code compared

Since CDONTS was deprecated since Windows 2000, ideally, all applications still using it should be rewritten to use the newer CDO object. However, it’s very common to see many enterprises prefer to make CDONTS work on the newer Windows Server to save time and money from re-writing their legacy applications.

August 18, 2015 Filed Under: How To Tagged With: Cdonts Dll, Classic ASP, Windows, Windows Server

How to Use CDONTS.DLL on Windows Server 2012 R2

With Microsoft ending the support on Windows 2003, many classic ASP applications that use cdonts.dll to send automatic emails (cdonts.newmail) still need to be migrated to the newer server (Windows Server 2012 R2). One way you can tell an application is using it is when you encounter the following error message on your browser.

CDONTS.NEWMAIL ActiveX error

CDONTS was already deprecated since Window 2000 and completely removed in Windows 2003. The ideal way to do it is to use the newer and more robust cdosys.dll. But in practicality, this will require a code re-write and many companies with legacy applications just don’t want to spend the time or money to do so. So you just to move all the codes and make them work the same way on Windows Server 2012 R2 which is 64-bit only.

Here are the steps to make cdonts.dll work on the current Windows Server 2012 R2. Please note, that the DLL itself is no longer available on the server as it is replaced with cdosys.dll. You also need to install an internal SMTP server first prior to performing these steps below or else you won’t be able to configure the permission on the mail pickup directory (Step 4).

Steps

  1. Copy CDONTS.DLL from the old server Windows Server 2003 (C:\WINNT\system32).

    CDONTS.DLL on Windows Server 2003

  2. Paste the DLL to the Windows Server 2012 R2 (C:\Windows\SysWOW64).

    CDONTS.DLL copied to Windows Server 2012 R2

  3. Launch Command Prompt (Admin) and type regsvr32 C:\Windows\SysWOW64\cdonts.dll

    Register cdonts.dll on Windows Server 2012 R2's command prompt

  4. Grant the required permissions on C:\inetpub\mailroot\pickup (or whichever mail directory you use if not the default). Typically, at the very least, you want to grant USERS group with Modify permissions.

  5. Reset IIS or restart the server (if not PROD).

  6. Test the application.

One last thing, we noticed that Windows Server 2012 R2 is more restrictive for e-mail formatting. You need to use an FQDN for your From: e-mail address. On Windows 2003, you can use any one-word “address” (i.e., From: “MySender”). On Windows Server 2012 R2, you need to add [email protected]. The e-mail format needs to be valid whether or not the e-mail address itself is legit.

We have used this method to migrate a dozen of ASP applications and this will buy more time for at least another eight more years before we need to re-write most of our applications.

Further Reading

Mastering Windows Server 2019
Mastering Windows Server 2016 Hyper-V

January 12, 2015 Filed Under: How To Tagged With: Cdonts Dll, Classic ASP, Windows 2012, Windows Server

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure