Share via


Binding Messages to Custom Forms

Binding Messages to Custom Forms

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Developers often want a user to view a custom form when the user opens a message.

The custom form example consists of two files, InstallMessage.vbs and CustomMessage.asp. InstallMessage.vbs creates the necessary folders, sets the Schema Collection Reference (SCR), and performs the form registration. The ASP file is executed whenever the user opens a message in that particular folder.

To run the custom form example

  1. Copy InstallMessage.vbs and CustomMessage.asp to your server.
  2. Run the .vbs file, typing in the appropriate URL when requested.
  3. Copy the CustomMessage.asp file into the resulting Bin directory.
  4. Go to that folder inside Outlook Web Access and create a new message.
  5. While still inside Outlook Web Access, click the icon to check for new messages and then double-click the message created in Step 4.
  6. The custom form appears.

The form itself is intentionally very simple. It only shows some HTML-generated text and the subject of the opened message.

Note  In Exchange System Manager, turn on Script Execute Permissions for ASP pages, and Scripts and Executables for Internet Server Application Programming Interface (ISAPI) filters. Otherwise, you will receive a 403 Permission Denied error.

InstallMessage.VBS

Install
Sub Install
'Get the folder
sFolder = InputBox("Please enter the URL to the folder: example https://serverName/public/foldername","Setup Instructions")
If Trim(sFolder) = "" Then
    Exit Sub
End If

'Create the app folder, pointing its SCR to the BIN subfolder
Set oDest = CreateObject("CDO.Folder")
oDest.Fields("urn:schemas-microsoft-com:exch-data:schema-collection-ref") = sFolder + "\bin"
odest.Fields("DAV:contentclass") = "urn:content-classes:folder"
oDest.Fields.Update
oDest.DataSource.SaveTo sFolder
'Create the BIN folder and make it invisible
Set oDest = CreateObject("CDO.Folder")
oDest.Fields("DAV:ishidden") = True
oDest.Fields.Update
oDest.DataSource.SaveTo sFolder +  "/bin"

'Fill the BIN folder with form registrations

Set oCon = CreateObject("ADODB.Connection")
oCon.ConnectionString = sFolder + "/bin"
oCon.Provider = "ExOledb.Datasource"
oCon.Open

'----------------------------------------------------
'Register the default page for the folder
Set oRec = CreateObject("ADODB.Record")
oRec.Open "default.reg", oCon, 3, 0
oRec.Fields("DAV:contentclass") = "urn:schemas-microsoft-com:office:forms#registration"
oRec.Fields("urn:schemas-microsoft-com:office:forms#contentclass") = "urn:content-classes:message"
oRec.Fields("urn:schemas-microsoft-com:office:forms#cmd") = "open"
oRec.Fields("urn:schemas-microsoft-com:office:forms#formurl") = "CustomMessage.asp"
oRec.Fields("urn:schemas-microsoft-com:office:forms#executeurl") = "CustomMessage.asp"
oRec.Fields.Update
oRec.Close

'Further instructions
MsgBox "Copy CustomMessage.ASP into the BIN directory. Enable script execution on the directory.", 64, "Further Instructions"

End Sub

CustomMessage.ASP

<%@Language=VBScript%>
<html>
<body>

<%
dataurl = request.querystring("dataurl")
Set c = Server.CreateObject("ADODB.Connection")
c.ConnectionString = dataurl
c.Provider = "ExOledb.Datasource"
c.Open
Set r = Server.CreateObject("ADODB.Record")
r.Open dataurl, c, 3
%>

<form class="form" method="post" action="<%=request.querystring("dataurl")%>?Cmd=save">

<h3>Message</h3>
Subject:<input type="text" name="urn:schemas:mailheader:subject" value="<%=r("urn:schemas:mailheader:subject")%>"

<input type="submit" value="Save">
</form>

<%
r.Close
c.Close
%>
</body>
</html>

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.