The error CDO.Message.1 (0x80040220) -The "SendUsing" configuration value is invalid is back again on IIS 7.5 and the reasons are also the same! inadequate permissions on the IIS Metabase due to which CDOSYS is unable to read the location of the Pickup Directory from the IIS Metabase. What has changed? The default Application Pool Identity in IIS 7.5 changed from NetworkService to AppPoolIdentity. For every Application Pool you create, the IIS Admin Process (WAS) will create a virtual account with the name of the new Application Pool and run the Application Pool's worker processes under this account. It is this account that is not able to read the location of the Pickup Directory from the IIS Metabase. You can read more about AppPoolIdentity here.
What are the available options to resolve the error? AFAIK there are 3 ways to resolve the error:
1) This is the easiest one, configure the application pool identity under which the site is running to NetworkService instead of AppPoolIdentity. From what I have seen the NetworkService account has “Special Permissions” on the /LM/SmtpSvc/ and /LM/SmtpSvc/1/ nodes in the IIS Metabase.
2) In case you do not want to change any permissions and are ok with code changes, then you can specify the smtpserverpickupdirectory and set its value to the path of pickup directory. Below is how we do it on VB Script.
'Send using the Pickup directory on the IIS server.Dim iMsgDim iConfDim FldsDim strHTMLConst cdoSendUsingPickup = 1set iMsg = CreateObject("CDO.Message")set iConf = CreateObject("CDO.Configuration")Set Flds = iConf.FieldsWith Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup 'The path may differ in your environment .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")="c:\Inetpub\mailroot\pickup" .UpdateEnd With' Build HTML for message body.strHTML = "<HTML>"strHTML = strHTML & "<HEAD>"strHTML = strHTML & "<BODY>"strHTML = strHTML & "<b> This is the test HTML message body</b></br>"strHTML = strHTML & "</BODY>"strHTML = strHTML & "</HTML>"With iMsg Set .Configuration = iConf .To = "test@test.com" .From = "test@test.com" .Subject = "This is a test CDOSYS message (Sent via Pickup)" .HTMLBody = strHTML .SendEnd With' Clean up variables.Set iMsg = NothingSet iConf = NothingSet Flds = NothingMsgBox "Mail Sent!"
Enjoy!
Thanks for the great tips, just an addition, You can also make an impersonation tag in web.config and set the identity in appPool to that user, that would work as well. Thanks
Are there any security implications by choosing option #3?
IMO there should not be any. All we are doing is giving read permissions.With earlier version of IIS we sometimes had to grand the IUSR_MachineName account read access to the metabase.
More details:
learn.iis.net/.../understanding-built-in-user-and-group-accounts-in-iis-7
how to use this in asp.net
thanks,
johnlen
You can use the System.Net.Mail in ASP.NET to send mail.
System.Net.Mail Namespace
msdn.microsoft.com/.../system.net.mail.aspx
Sample
archive.msdn.microsoft.com/.../View.aspx