Click here to Skip to main content
13,145,603 members (45,389 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 29 Apr 2004

Forwarding of emails with CDO 1.2 and Exchange

, 29 Apr 2004
Rate this:
Please Sign up or sign in to vote.
How to use CDO for forwarding of emails with Exchange.


This article explains the forwarding of emails with CDO and Exchange.

Using the code

CDO.DLL, responsible for CDO 1.2 (Collaboration Data Objects), is installed on the web server during the installation of Exchange 5.5 or Outlook for Web Applications (OWA).

Unlike CDONTS (Collaboration Data Objects for NT Server), CDO 1.x only works with the users who are authenticated on the Exchange Server.

In contrast to this, every user who has got the right to create ASP scripts can send emails via CDONTS.

Besides the access to the SMTP function of the exchange server, CDO 1.x offers access to further objects such as address book, calendar, dates, etc.

Therefore, the syntax for sending emails has slightly changed with regard to CDONTS. But this change is offset by the great amount of new possibilities.


The following conditions must be fulfilled:

  • A mailbox must exist on the Exchange Server.
  • CDO 1.x must be installed on the web server.
  • The ASP script, which executes the mail code, must be run under the NT account of the mailbox owner.
  • The information, under which rights which ASP scripts are executed, is recorded in the metabase of the web server. If the file name is changed, this information will not be updated in the metabase.

Therefore, it is recommended to create a separate subdirectory with the corresponding right.

The assignment of the right is done in “Properties”.

The Code

With the following ASP code, emails can be send with CDO 1.x via the Exchange Server:

In rows 1 and 2, the address of the Exchange Server as well as the alias of the mail account is defined. This information is combined to the user profile in row 4. In row 5, a MAPI session (Messaging Application Programming Interface) to the Exchange Server is created. With row 6, the user is registered. In rows 8 to 10, the subject and the text of the email are passed. Rows 12 to 14 pass the recipient and resolve an alias name into an email address. In row 16, the mail is sent. In rows 17 to 20, the session is closed and the objects are released.

1    Const cStrServer        = "<name of exchange server>"
2    Const cStrMailbox       = "<Mail-Account Alias>"
3    bstrProfileInfo = cStrServer & vbLf & cStrMailbox 
5    Set objSess = Server.CreateObject("mapi.session") 
6    objSess.Logon "", "", False, True, 0, True, bstrProfileInfo
8    Set objFBMess = objSess.Outbox.Messages.Add
9    objFBMess.Subject = "Test CDO-Mail"'Subject
10   objFBMess.Text = "Content of the mail" mailtext

12   Set objRecips = objFjRecips = objFBMess.Recipients
13   objRecips.Add ("") 

14   objRecips.Resolve
16   objFBMess.Send
18   objSess.Logoff
19   Set objFBMess = nothing
20   Set objRecip = nothing
21   Set objSess = nothing

Possible Error

If the registration on the Exchange Server fails, the following error message appears:

Collaboration Data Objects error '000004f9' 
The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]
/wvs/_mailtest1.asp, row 13

In most cases, the error is due to the user’s authorization.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Christian Kiefer
Web Developer
Germany Germany
Christian Kiefer works as a Consultant and developer for internet-software in the middle of Germany.

As an Internet specialist, Christian has designed and developed many ASP based applications that take advantage of advanced database and directory services.

Christian specializes in advanced Internet technologies such as DHTML, ASP, ADSI, XML, and ASP.NET.

You may also be interested in...

Comments and Discussions

GeneralHTML Support Pin
pks6z821-Apr-08 9:31
memberpks6z821-Apr-08 9:31 
GeneralAGGHHH - this is painful Pin
smcpoland17-Oct-04 3:34
membersmcpoland17-Oct-04 3:34 
GeneralRe: AGGHHH - this is painful Pin
Christian Kiefer28-Oct-04 22:37
memberChristian Kiefer28-Oct-04 22:37 
QuestionCheck valid email account? Pin
Tommy EE3627-Sep-04 21:01
memberTommy EE3627-Sep-04 21:01 
AnswerRe: Check valid email account? Pin
Anonymous7-Oct-04 23:58
sussAnonymous7-Oct-04 23:58 
GeneralRe: Check valid email account -> solution Pin
Christian Kiefer3-Nov-04 1:54
memberChristian Kiefer3-Nov-04 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 30 Apr 2004
Article Copyright 2004 by Christian Kiefer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid