Click to See Complete Forum and Search --> : CDOSYS - Internal Server Error


siddharthpriya
03-16-2005, 04:27 PM
Hi,

I am trying to use CDOSYS to send emails through a different SMTP server. However, when I use the code below, I keep getting the dreaded Internal Server error (The page doesnt even reach the response.end after if err.number<>0). If I comment the .item(cdoSendUsingMethod) = cdoSendUsingPort line, I dont get the Internal server error but the email is generated and just saved on the IIS server's mailroot/Queue directory. The same thing happens if I change it to 1 (I dont know the CDO constant for that and what the numbers 1 and 2 mean for the SendUsing property). Could someone let me know what could be causing this problem?

Thanks.

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->

<%
Function sendMail(dictRecipients,dictCC,strSubject,strBodyText,strMailFrom,boolEncrypt)

'On Error Resume Next

' Function private variables declaration
Dim objMail, objConf
Dim intCounter
Const cdoSendUsingPort = 2
' Function private variables initialization
set objMail = Server.CreateObject("CDO.Message")
Set objConf = Server.CreateObject("CDO.Configuration")

With objConf.Fields
' To use a remote SMTP server
.item(cdoSMTPServer) = Application("MailServer")
.item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.item(cdoSendUsingMethod) = cdoSendUsingPort
.update
End With

Set objMail.Configuration = objConf

' Function implementation
objMail.From = strMailFrom
objMail.Subject = strSubject
objMail.TextBody = strBodyText

' Get all to addresses from dictRecipients
For Each objKey In dictRecipients.Keys
objMail.To = dictRecipients.Item(objKey)
Next

' Get all CC addresses from dictCC
' For Each objKey In dictCC.Keys
' objMail.CC = dictCC.Item(objKey)
' Next
' response.write "sending mail" & "<br>"

objMail.Fields.Update
objMail.Send

if err.number <> 0 then
response.write err.description
response.end
sendMail = false
else
sendMail = true
end if

set objKey = nothing
set objMail = nothing
End Function
%>