Saturday, October 4, 2008

[How To] Installing CDO for windows 2003

Microsoft Windows 2003 does not have Collaboration Data Objects (CDO) for NTS (CDONTS) nor for Exchange 2000 (CDOEX) installed. Therefore, applications that uses CDONT or CDOEX will not function. To install them use the steps below:

1. Download cdo.zip file. Then extract both (or only one as needed) to %systemroot%\system32.

2. Register the files using the commands below:

regsvr32 "%systemroot%\system32\cdonts.dll"

regsvr32 "%systemroot%\system32\cdoex.dll

3. If you have SMTP server then goto step 8, otherwise continue to step 4 to install and setup local SMTP service.

4. Check to see if SMTP services is installed by going to Administrative Tools, IIS and expand local machine, if SMTP service is listen then its installed otherwise continue to step 5 for installing SMTP service.

5. To install SMTP perform the following operation: Go to Control Panel, Add/Remove Programs, Add/Remove Windows Components, Application Server, IIS, Check on SMTP service, Click OK.

6. Change the port number for SMTP service. Default port is 25. Use 25 only if you don't have another SMTP service running. If another SMTP service is already running on your server you should switch IIS SMTP port to another, for example to 8025.

You can do through IIS management console: Control Panel, IIS, expand "local computer", SMTP, Properties, General tab, click on Advanced button, Edit.

7. Configure SMTP service. The main things are to set a valid full-qualified domain name for SMTP service: Control Panel, IIS, expand "local computer", SMTP, Properties, Delivery tab, click on Advanced button and configure Security for SMTP service.

It's necessary to grant permissions to IIS_WPG standard IIS Worker Process Group. Control Panel, IIS , expand "local computer", SMTP, Properties, Security tab , click on Add button, click Object types... button, check on Groups item, click OK, type IIS_WPG as object name to add , click OK.

Additional setting: Choose Authentication and tick Anonymous Access and Integrated Windows Authentication. Click OK, and then click CONNECTION. Configure RELAY settings as you wish. Click the DELIVERY tab then click ADVANCED. Set the MAX hop count to whatever you like but we recommend at least 30

Now IIS SMTP service is configured and ready to work.

8. Now to test the CDO component & the SMTP Service, use the following code:

Dim objCDO, objCDOConfig, objFields

Set objCDO = CreateObject("CDO.Message.1")
Set objCDOConfig = CreateObject("CDO.Configuration")
Set objFields = objCDOConfig.Fields

With objFields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "[Your SMTP SERVER" ' localhost if you are using your local SMTP service
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/SendUsing") = 2

' If your SMTP Service require authentication that you need to set authentication,username, and password.
' otherwise, just remark the these rows
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2 ' cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[UserName]"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "[Password]"
.Update
End With

With objCDO
.Configuration = objCDOConfig
.To = """FirstName LastName"" <[Emailadress]>"
.BCC = """FirstName LastName"" <[Emailadress]>"
.From = """FirstName LastName"" <[Emailadress]>"
.Subject = "[Subject]"
.TextBody = "[Body]"
.HTMLBody = "[Body]"
.AutoGenerateTextBody = False
.Send
End With
set objCDo = Nothing

No comments: