Padding Padding
Janet
Systems
 Register  Login 
Telephone  01628 566 178
Website Design, Hosting and Software Services
  Search 
Padding
corner Padding corner
Padding Padding
corner Padding corner
 ASP Articles

The implementation of the CDONTs e-mail method used in asp has changed in Windows 2003 server.

Example old CDONTS implementation

Set m1 = CreateObject("CDONTS.NewMail")
m1.From = fromAddr
m1.To = recipients
m1.Subject = subject
m1.Body = CStr("" & body)
m1.Send

The code below is an example of the new cdo format.

Set objErrMail= Server.CreateObject("CDO.Message")
With objErrMail
.From = fromAddr
.To = recipients
.Subject = subject
.HTMLBody = CStr("" & body)
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myWebServer.com"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.Send
End With

Note the sendusing schema has options as follows:

  1. use localhost
  2. use specified mail server

In our experience a value of 1 is simpler to configure.

The code below has been used to send e-mails via a remote SMTP server. Note the first line omits the word "server" as this is run as a local vbscript.

Set objErrMail=CreateObject("CDO.Message")
With objErrMail
.From = myaddress@myaddress.com
.To = myfriend@hisaddress.com
.Subject = "Type in your subject here"
.HTMLBody = "<h1> Type in the body of your message here </h1>"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'use 1 for local or 2 for remote smtp server
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserveraddress.com" 'enter your smtp server
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'port number 25 is standard
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'use 0 for no auth, 1 for basic
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername" ' enter your email username
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword" 'enter email password
.Configuration.Fields.Update
.Send
End With

NAT January 2007 (Revised)


This article viewed: 3331 times Back

Copyright © 2004-2007 Janet Systems Ltd.

 Print   

DotNetNuke Website design and hosting from £15.00 per month. More...

Looking for a website design company in the Thames Valley, call us on 01628 566178

DotNetNuke Modules
DotNetNuke Modules availalble from Janet Systems

DotNetNuke Skins
DotNetNukeSkins.gif

from Janet Systems

Padding
Copyright 2002-2008 Janet Systems Ltd.   Terms Of Use  Privacy Statement Tuesday, May 13, 2008