Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.ASP email send returning 500 - Internal server error IIS

Posted on 2013-07-01
8
Medium Priority
?
3,915 Views
Last Modified: 2013-07-17
I've copied some pages from our old server to a new one, this page is no longer sending emails and instead is throwing an error.  I expect I haven't set something right with the server/service since it worked before and the code hasn't changed.  Here's the sub that's dieing:

sub send_email(x_subject, x_body, x_to, x_from)
'used for sending mail to a single recipient
      sch = "http://schemas.microsoft.com/cdo/configuration/
    set cdoConfig = CreateObject("CDO.Configuration")
    with cdoConfig.Fields
        .Item(sch & "sendusing") = 2
            .Item(sch & "smtpserver") = "127.0.0.1"
        .update
    end with

    set cdoMessage = CreateObject("CDO.Message")  
    with cdoMessage
        set .Configuration = cdoConfig
        .From = x_from
            .To = x_to
        .Subject = x_subject
        .HtmlBody = x_body
        .Send
    end with
 
    set cdoMessage = nothing  
    set cdoConfig = nothing
end sub

If I comment out the call to the sub there's no error, but it also doesn't send the email, obviously.
0
Comment
Question by:Rossamino
  • 5
  • 3
8 Comments
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39291312
Try logging into the server to see the actual error or turn on errors in iis.

Chances are you just need to send via pick up changing this line

  .Item(sch & "sendusing") = 2

to

  .Item(sch & "sendusing") = 1

The 1 means pickup  http://msdn.microsoft.com/en-us/library/exchange/ms873037(v=exchg.65).aspx

Does your smtp need to user/pass?  I use this site as a sample source http://www.paulsadowski.com/wsh/cdo.htm
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39291315
0
 

Author Comment

by:Rossamino
ID: 39311356
That hasn't fixed anything. What's the service that runs SMTP? Not sure if that's even installed.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39312504
If you are getting 500 internal error, that means you do not have detailed errors turned on.  You will need to take care of that, then find the actual error and line number in your code.  Otherwise, I can't really give you any advice other then guesses.

Did you try changing your sendusing to  pickup (1)?

Do you need to authenticate?  great examples here http://www.paulsadowski.com/wsh/cdo.htm

Please get a detailed error and line number and I can help you.
0
 

Author Comment

by:Rossamino
ID: 39326641
I'm looking at IIS v7.5... When I look at the .ASP Debugging Properties configuration for either the site or the directory everything's set to true except "Log Errors to NT log".  Why is it still throwing 500 instead of something useful?
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39326778
Can you log into the server and run the page?  There is a setting somewhere that can send the error to the remote client and off the top of my head I can't remember. When I error check, I just log into the server.  If you are on shared hosting, you may need to contact the host service to do this for you.
0
 

Author Comment

by:Rossamino
ID: 39330211
We're using a virtual server on AWS.

The log file has this to say (sendorderemail.asp is the page that's failing).  The first time is with .Item(sch & "sendusing") = 1 and the second time is with it set to 2:

2013-07-16 15:06:03 10.36.106.179 POST /sendorderemail.asp |97|80040213|The_transport_failed_to_connect_to_the_server.__ 443 - 109.32.157.192 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1500.72+Safari/537.36 500 0 0 1664


2013-07-16 15:06:03 10.36.106.179 POST /sendorderemail.asp |97|80040213|The_transport_failed_to_connect_to_the_server.__ 443 - 109.32.157.192 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1500.72+Safari/537.36 500 0 0 1664
0
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 39330266
The_transport_failed_to_connect_to_the_server.

You probably need to authenticate.  Look here http://www.paulsadowski.com/wsh/cdo.htm for the sample.  I copied below, make sure to use your own info.  

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = """Me"" <me@my.com>" 
objMessage.To = "test@paulsadowski.com" 
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question