Deleting Items in the Mailbox (ADO)
Topic Last Modified: 2009-07-23
This example shows how to delete items in a mailbox by using ADO.
Example
Description
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.
Code
[VBScript]
' 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>