Sending mail with ASP on Win2K3 IIS6, SMTP

Hi,
I am trying to send an email from an ASP page running on Windows 2003. I am moving a site from jsp/linux to asp/windows, and have not used SMTP (IIS) on windows before. I have installed SMTP and it is running. When I run my script I get this error:

CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
/en/mail2.asp, line 19         {MyMail.Send() - see below}

This is the code
<%
Dim MyMail
Set MyMail = Server.CreateObject("CDO.Message")
MyMail.From = "josh@golfbox.com.au"
MyMail.To = "josh@golfbox.com.au"
MyMail.Subject = "Test email"
MyMail.TextBody = "Test email"
MyMail.Fields("urn:schemas:httpmail:importance").Value = 2
MyMail.Fields.Update()
MyMail.Send()
Set MyMail = Nothing
%>

I have also tried this code (which I found on this site).

<%
strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
CALL SendMailCDOSYS("josh@golfbox.com.au","josh@golfbox.com.au","test",strMailBody,True,"localhost")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
          ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTo
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub
%>

This code does not return an error but it does not send any emails either. The mail directories in C:\Inetpub\mailroot\ are all empty.

I only need to send emails from the server. The machine is currently on the local network (192.168.1.4), while I am working on the site. It is a new (2 week old) machine. I think the SMTP may not be configured correctly.

Any suggestions?

Joshua
JSmalesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

usankarCommented:
check if the mails are getting queued up(QUEUE folder) or going to the bad mails folder(BADMAIL)
0
af500Commented:
is the asp is running on the same server as the SMTP ... try JUST this:
<%
Dim MyMail
Set MyMail = Server.CreateObject("CDO.Message")
MyMail.From = "josh@golfbox.com.au"
MyMail.To = "josh@golfbox.com.au"
MyMail.Subject = "Test email"
MyMail.TextBody = "Test email"
MyMail.Send()
Set MyMail = Nothing
%>
0
JSmalesAuthor Commented:
The queue folder & bad mails folder are both empty.

The ASP and SMTP are on the same server. When I try:

<%
Dim MyMail
Set MyMail = Server.CreateObject("CDO.Message")
MyMail.From = "josh@golfbox.com.au"
MyMail.To = "josh@golfbox.com.au"
MyMail.Subject = "Test email"
MyMail.TextBody = "Test email"
MyMail.Send()                        <-- Line 16
Set MyMail = Nothing
%>

It returns:

CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
/en/mail3.asp, line 16
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

JSmalesAuthor Commented:
Ok, I have manually tested the SMTP server using

http://support.microsoft.com/default.aspx?scid=kb;en-us;323350

and this adds an email to the queue folder. When I run the script below, an email is added to the queue folder, but is not sent.

<%
strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
CALL SendMailCDOSYS("josh@golfbox.com.au","josh@golfbox.com.au","test",strMailBody,True,"localhost")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
          ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTo
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub
%>
0
JSmalesAuthor Commented:
Ok, I manage to solve the problem. I was trying to send the email to a local network address, that was not setup in our internal DNS. I have been able to send externally, it just did not occur to try until now.

I am using  SendMailCDOSYS code to send the emails.
0
CetusMODCommented:
Question PAQ'd
500 points refunded.

CetusMOD
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.