Share via


Deleting Items in the Mailbox Using ADO

Deleting Items in the Mailbox Using ADO

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.

VBScript

Note  The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.

' Deleting Items in the Mailbox Using ADO
-->

<!--

' Build Instructions
' Save the file to a newly-created virtual directory under the wwwroot.
-->


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%

Response.Write "User: " & Request.ServerVariables("AUTH_USER") & "</BR>"
Dim Rec
Dim strURL

Dim DomainName
Dim strLocalPath

' If you have a reference to Microsoft ActiveX Data Objects 2.5 Library (msado15.tlb),
' comment out the following line, because adModeReadWrite is defined in msado15.tlb.
const adModeReadWrite = 3

' Specify your own domain.
DomainName = "mydomain.contoso.com"

' Specify a URL to the folder or the item to delete.
strLocalPath = "MBX/User1/Inbox"

Set Rec = CreateObject("ADODB.Record")

' This is the URL for the folder.
strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath

' You must open the record as read/write to be able to delete the record.
Rec.Open strURL,,adModeReadWrite

' Delete the record from the folder.
' The record needs to be formatted exactly as follows if you are dragging a text file into the
' folder as a "Free Doc". If it is a plain e-mail message, then the syntax is as follows:
' "/<Msg Subject>.EML"

Rec.DeleteRecord("test3.EML")
Rec.Close

set rec = nothing

Response.Write "Message deleted..." & "</BR>"
%>

<P> </P>

</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.