PDA

View Full Version : cdonts problems


esthera
05-31-2005, 07:34 PM
i was having a problem with messages sent using cdonts not getting delivered.
I spoke to the hosting co. and they said I need to set the mail server.
Can you set a mail server with cdonts? how?

Freon22
05-31-2005, 09:58 PM
Can you set a mail server with cdonts? how?

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from
objCDOMail.From = strWebsiteName & " <" & strForumEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strUserName & " <" & strUserEmail & ">"

'The subject of the e-mail
objCDOMail.Subject = strSubject

'The main body of the e-amil
objCDOMail.Body = strEmailBody

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 1

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server mail object
Set objCDOMail = Nothing

miranda
05-31-2005, 10:36 PM
Use CDO for Win2k not the older CDO for Win NT aka CDONTS


Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
Dim objMail
Dim myServer
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")
sTo = "someone@someisp.com"
sFrom = "me@someisp.com"
sSubject = "CDO Test"
sTextBody = "Test email from " & sFrom

'the line below can use either an ip address of the mail server or the string of
'the mail server supplied by your hosting company
myServer = "smtp.yourmailserver.com" 'this is your mail server

Set objConf = Server.CreateObject("CDO.Configuration")
Set objFields = objConf.Fields

objFields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'specify the port to use here!!!!

objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = myServer
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

objFields.Update
Set objMail.Configuration = objConf

'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = sTextBody

'Send the email
objMail.Send()

'Clean-up mail object
Set objMail = Nothing
Set objConf = Nothing

esthera
06-01-2005, 06:33 AM
anyway to set the server for cdonts?

miranda
06-01-2005, 03:30 PM
use the newer version instead. you don't use software meant for windows 3.0 do you? so why try to use something for windows NT?

Gary Williams
06-01-2005, 04:15 PM
Hi Miranda,

In the cdosys configuration, doesn't the:


objFields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

refer to sending over the network, etc and the:

objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

sets the port number.

Or am I missing the point :(

Regards

Gary

miranda
06-01-2005, 04:47 PM
Gary, you are right, I had read it wrong. According to the enumeration SendUsing = 2 designates to send over the network vs SendUsing = 1 which is the default and specifies to use the local computers smtp service.
You will need to include the line designating the server port if port 25 (the default is closed).