简体   繁体   中英

Code after cdo.message.send won't execute in classic ASP

Here is my Complete code. There is no other code in the entire page.

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="abcd@example.com"
myMail.To="abc@example.com"
myMail.TextBody="This is a message. "
Response.write "Execution Reached Before Send!"
myMail.Send
Response.write "Execution Reached After Send!"
set myMail=nothing

When I run this asp page, the result I am getting is "Execution Reached Before Send!". There is no other error messages. All I can understand from this is anything after the myMail.Send is not being executed and I am not receiving any emails also.

I am using Windows Server 2008 R2 Standard (Service Pack 1). SMTP mail server is installed on the local machine. I created a test email and dropped in "C:\\inetpub\\mailroot\\Pickup" folder and it worked perfectly.

The code worked after I added these four lines before the send.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM