So when reading other blogs, they often tell you to change from Pickup Directory to Port or vise versa.
This code below came from an old Windows 2003 machine running IIS. I’m migrating to an Amazon EC2 instance running Windows 2012. My application is a classic ASP application that I have never rewritten. I remember having similar difficulties back then, decided Microsoft’s SMTP was too complicated, tried some others, and ended up running MailEnable.
I have a VBScript Class in a separate file that can be shared by any program that needs to send an email. That’s the first block of code below. The second block of is uses the class to try to send the email. It was bombing on the line that said “cdomsg.Send”.
public function send
Set cdomsg = CreateObject(“CDO.Message”)
Set iConf = Server.CreateObject(“CDO.Configuration”)
Set Flds = iConf.Fields
‘ Neal changed 12/12/2007 – was getting error:
‘ Arguments are of the wrong type, are out of acceptable range,
‘ or are in conflict with one another
‘ Actually – had to add the MetaData clause at the top
Flds.Item(cdoSendUsingMethod) = 1 ‘ 1=pickup 2=port
‘ The value of 2 might require a user/pass, but you must specify port & server
‘Flds.Item(“http://schemas.microsoft.com/cdo/configuration/sendusername”) = “MyUser”
‘Flds.Item(“http://schemas.microsoft.com/cdo/configuration/sendusername”) = “MyPass”
Flds.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory”) = “c:\inetpub\mailroot\pickup”
cdomsg.from = emailFrom
cdomsg.to = emailTo
cdomsg.subject = emailSubject
cdomsg.textbody = emailBody
Set cdomsg = Nothing ‘ not allowed to reuse it for another message
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library"-->
Response.Write "Attempt to send mail "
Set objMail = new Mail
objMail.emailFrom = "firstname.lastname@example.org"
objMail.emailTo = "email@example.com"
objMail.emailSubject = "TestMail.asp from mydomain.com server"
objMail.emailBody = "Body of email, this is a test"
objMail.Send ' was getting error on this line when attempting to send email
Set objMail = Nothing ' not allowed to reuse it for another message
Response.Write "Mail sent"
The Steps I Took To Solve the Problem
Obviously, I had to get IIS installed. One possible issue is that I installed it, but I didn’t configure it.
1. I basically followed these steps to Setup and Configure SMTP. I did not setup their firewall rules, because I’m running IIS and SMTP on the very same server. I did one thing not on their list. From the “Security” tab of the SMTP Virtual Server Properties, I added the local user account tied to the Application Pool.
2. I did add a local user account, assigned that account to my IIS Application Pool, restart the app pool. I gave that account access to my IIS files directory, and to the pickup directory. At this point, I’m not sure that was needed or not.
3. I never got to work using 2=port, only 1=pickup.