This topic is locked
[SOLVED]

 CDOSYS instead of SMTP

4/10/2007 6:07:28 PM
ASPRunnerPro General questions
M
mfred author

Security restrictions prevent use of the SMTP email method for emailing the add page and edit page information. I have created other applications using CDOSYS but the cosing conflicts with ASPRunner code. So I ran a search, found the code that others used and setup the code in the events. But I get an error at "objCDOSYSMail.HTMLBody =" in the following code. Can anyone indicate where I errored?
The code is:

' send email

Dim objCDOSYSCon

Set objCDOSYSMail = Server.CreateObject("CDO.Message")

Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "SMTP server"

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout";) = 60

objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon

objCDOSYSMail.From = "webmaster@ridgways.com"

objCDOSYSMail.To = rs("CallerEmail")

objCDOSYSMail.Subject = "Service Call Update"

objCDOSYSMail.HTMLBody =

"Call ID: " & rs("CallID") & "<BR>" &

"Status: " & rs("Status") & "<BR>" &

"Date of Call: " & rs("DateofCall") & "<BR>" &

"Time of Call: " & rs("TimeofCall") & "<BR>" &

"Caller: " & rs("Caller") & "<BR>" &

"Intake Person: " & rs("IntakePerson") & "<BR>" &

"Device and Location: " & rs("DeviceLocation") & "<BR>" &

"Issue: " & rs("Issue") & "<BR>" &

"Service Call Placed To: " & rs("ServiceCallPlacedTo") & "<BR>" &

"Time Placed: " & rs("TimePlaced") & <BR> &

"Resolution and Comments: " & rs("ResolutionComments") & "<BR>" &

"Date Service Completed: " & rs("DateServiceCompleted") & "<BR>" &

"Time Service Completed: " & rs("TimeServiceCompleted") & "<BR>" &
objCDOSYSMail.Send

Set objCDOSYSMail = Nothing

Set objCDOSYSCon = Nothing

Admin 4/10/2007

Mfred,
this code still uses SMTP method to send emails.
I can see at least two errors here:
1.

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "SMTP server"


Put correct SMTP server address there.
2. The following code should go as a single line:

objCDOSYSMail.HTMLBody =

"Call ID: " & rs("CallID") & "<BR>" &

"Status: " & rs("Status") & "<BR>" &

"Date of Call: " & rs("DateofCall") & "<BR>" &

"Time of Call: " & rs("TimeofCall") & "<BR>" &

"Caller: " & rs("Caller") & "<BR>" &

"Intake Person: " & rs("IntakePerson") & "<BR>" &

"Device and Location: " & rs("DeviceLocation") & "<BR>" &

"Issue: " & rs("Issue") & "<BR>" &

"Service Call Placed To: " & rs("ServiceCallPlacedTo") & "<BR>" &

"Time Placed: " & rs("TimePlaced") & <BR> &

"Resolution and Comments: " & rs("ResolutionComments") & "<BR>" &

"Date Service Completed: " & rs("DateServiceCompleted") & "<BR>" &

"Time Service Completed: " & rs("TimeServiceCompleted") & "<BR>" &
M
mfred author 4/11/2007

I am not getting it to work. I am back with the default SMTP method, which only works when the receiving email is from the same domain as the designated for "from". I tried 2 different SMPT servers. one gives: ""The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for xxxx@xxxxxx.com" or "The server rejected one or more recipient addresses. The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)"
The code which seems relevant is in commonfunctions.asp:

cFrom = "xxxx@xxxxxxxx.com"

cSmtpServer = "mailhost.xxxxxxxx.com"

cSmtpPort = "25"

cSMTPUser = "xxxxxxxxxx"

cSMTPPassword = "xxxxxxxxx"

Admin 4/11/2007

Nothing is wrong with this code. The problem is that SMTP do not accept some or all recipient addresses.
Ask mail server admin what you need to do in order to resolve the issue.
PS. Usually you can use local SMTP server which should work fine.

C
clig 4/13/2007

I am not getting it to work. I am back with the default SMTP method, which only works when the receiving email is from the same domain as the designated for "from". I tried 2 different SMPT servers. one gives: ""The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for xxxx@xxxxxx.com" or "The server rejected one or more recipient addresses. The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)"

The code which seems relevant is in commonfunctions.asp:

cFrom = "xxxx@xxxxxxxx.com"

cSmtpServer = "mailhost.xxxxxxxx.com"

cSmtpPort = "25"

cSMTPUser = "xxxxxxxxxx"

cSMTPPassword = "xxxxxxxxx"


<%

Dim ObjSendMail

Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2 'Send the message using the network (SMTP over the network).

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver";) ="servername"

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25

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

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout";) = 60
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";) = 1 'basic (clear-text) authentication

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername";) ="somemail@yourserver.com"

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword";) ="yourpassword"
ObjSendMail.Configuration.Fields.Update
'End remote SMTP server configuration section==

ObjSendMail.To = "foo@email.com;"

ObjSendMail.Subject = "New Central NTSS Tech Support Referral Submitted"

ObjSendMail.From = "NTSS@email.com"
' switch the comments around to send an html email instead

ObjSendMail.HTMLBody = "Go to: <a href=http://servername/TechSupport/Referrals/>http://servername/TechSupport/Referrals/</a>; - to assign the ticket to a Tech Support Advisor."

'ObjSendMail.TextBody = ""
ObjSendMail.Send
Set ObjSendMail = Nothing

%>
This sample works as is on IIS 6 - You could call this as a separate asp - pass session variables to it...
IIS 5 - Use CDONTS...