Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

   

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath
 
 

Render an attachment in Exchange 2000

Rendering an attachment of an object, such as Email, via the browser in the WSS is a little trickier than rendering a document.  To accomplish this, you need to understand how Exchange stores attachments. Attachments are stored as siblings of the parent object.  Lets use the Exchange email object as an example. An email,  when stored, is saved as the primary body-part (CDO Ex Terminology) of itself. Any attachment that follows is saved as a subsequent body-part. The following are two examples that illustrate this. In method one, you will manually construct the link.  In method two, you use a CDO object. 

 

Method one:  Manually constructing the link

Syntax

http://<Server Name>/<Folder Path>/<Object name>/ 1_multipart_xF8FF_<attachment Index>_<attachment Name>

Parameters

<Server Name>

Specifies the name of your Exchange 2000 server

<Folder Path>

Specifies the storage path of your document

<Object Name>

          Specifies the name of object that contains your attachment

<Attachment Index>

          Specifies the index number of your attachment

<Attachment Name>

          Specifies the name of your attachment

Example

The following example illustrates a manually constructed link.

 

http://MyServer/MyStore/MyFolder/My.eml/1_multipart_xF8FF_2_My.doc

 

Method Two:  Constructing an attachment link using CDO

The example code below will retrieve all attachments in the http://Myserver/MyStore/MyParentFolder/MyFolder/My.Eml message that have a display name of My.doc. This example works exactly as method one does if the display name for you document is unique within the context of the folder. Please also reference my article on generating unique IDs.

Example

Set Conn = Server.CreateObject("ADODB.Connection")

Set Msg = Server.CreateObject("CDO.Message")

strDataURL = "http://MyServer/MyStore/"

With Conn

.Provider = "ExOLEDB.DataSource"

.Open strDataURL

End With

strDataURL = "http://MyServer/MyStore/MyFolder/My.Eml/"

With Msg

.DataSource.Open strDataURL, Conn, 3

For I = 2 To .Attachments.Count

strName = .Attachments(I).FileName

If ucase(strName) = "MY.DOC" Then

          strHREF = strDataURL & “1_multipart_xF8FF_” & I & “_” & strName

    Response.Write ("<A href='" & strHREF & "'>" & strName & "</A>")

End IF

Next

.MoveNext

End With


RETURN to my Article Index


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Stephen Bryant or Pro Exchange. OutlookExchange.Com, Stephen Bryant and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Copyright Stephen Bryant 2008