Click here to Skip to main content
Click here to Skip to main content

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.

Introduction

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.

Conditions

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 
4
5    Set objSess = Server.CreateObject("mapi.session") 
6    objSess.Logon "", "", False, True, 0, True, bstrProfileInfo
7
8    Set objFBMess = objSess.Outbox.Messages.Add
9    objFBMess.Subject = "Test CDO-Mail"'Subject
10   objFBMess.Text = "Content of the mail" mailtext
11      

12   Set objRecips = objFjRecips = objFBMess.Recipients
13   objRecips.Add ("mustermann@testweb.de") 

14   objRecips.Resolve
15
16   objFBMess.Send
17
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.

License

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

Share

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.

Comments and Discussions

 
GeneralHTML Support Pinmemberpks6z821-Apr-08 9:31 
GeneralAGGHHH - this is painful Pinmembersmcpoland17-Oct-04 3:34 
GeneralRe: AGGHHH - this is painful PinmemberChristian Kiefer28-Oct-04 22:37 
QuestionCheck valid email account? PinmemberTommy EE3627-Sep-04 21:01 
AnswerRe: Check valid email account? PinsussAnonymous7-Oct-04 23:58 
GeneralRe: Check valid email account -> solution PinmemberChristian Kiefer3-Nov-04 1:54 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 30 Apr 2004
Article Copyright 2004 by Christian Kiefer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid