Share via


Deleting a Contact from the Exchange Store (WebDAV)

Topic Last Modified: 2006-12-05

Deleting a contact involves removing the contact item from the Exchange store.

Example

Description

The following example uses the DELETE Method to delete a contact for "JoLynn Dobney" from a user's Contacts folder in the Exchange store.

See Constructing Exchange Store HTTP URLs and Authentication and Security Using WebDAV for more information.

Code

' Declare variables to be used.
Dim objRequest 'As MSXML.XMLHTTPRequest
Dim strURL 'As String

' Specify the URL of the object to be deleted.
strURL = "https://ServerName/Exchange/UserName/Contacts/JoLynnDobney.eml"

' Create an HTTP request object.
Set objRequest = CreateObject("Microsoft.xmlhttp")

' Open the object, assigning it a method.
objRequest.open "DELETE", strURL, False, "UserName", "Password"

' Send the request, using the XML document as the body.
objRequest.send

'Display the results.
If (objRequest.Status >= 200 And objRequest.Status < 300) Then
    MsgBox "Success!   " & "Results = " & objRequest.Status & _
        ": " & objRequest.statusText
ElseIf objRequest.Status = 401 Then
    MsgBox "You don't have permission to delete the contact. " & _
        "Please check your permissions on this item."
ElseIf (objRequest.Status >= 500 And objRequest.Status < 600) Then
    MsgBox "An error occurred on the server."
Else
    MsgBox "Request Failed.  Results = " & objRequest.Status & _
        ": " & objRequest.statusText
End If

Set objRequest = Nothing