Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
931 views
in Technique[技术] by (71.8m points)

email - SMTP configuration SendUsing configuration value is invalid with ASP-Classic

I'm trying to get an email sent using ASP classic, and am having trouble with SMTP configuration.

The error:

CDO.Message.1 error '80040220' The "SendUsing" configuration value is invalid.

The Code(for the email itself):

Set objMsg = Server.CreateObject("CDO.Message")  
objMsg.From     = "name@name.com"  
objMsg.To       = "themetatron@gmail.com"  
objMsg.Subject  = "Procurement Ally Update"  
objMsg.TextBody = strBody 

The Code I tried to configure with (pt 1):

sch = "http://schemas.microsoft.com/cdo/configuration/"  
Set cdoConfig = CreateObject("CDO.Configuration")   
    With cdoConfig.Fields   
        .Item(sch & "smtpserver") = "127.0.0.1"   
        .update   
    End With   

That didn't work, so I tried:

objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"  
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  
objMsg.Configuration.Fields.Update 

That also didn't work.

(Yes, I didn't show it, but at the end there's a call to objMsg.Send)

As far as I can tell, the local boxes SMTP service is running and ready to do its duty.

Can anyone help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are specifying an smptserver, be sure to set your 'sendusing' field to 2 (or cdoSendUsingPort) as well:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...