MAPIDeleteMail

Syntax

MAPIDeleteMail(Session, UIParam, MessageID$, Flags, Reserved)

Remarks

Deletes a message from the Inbox. Before calling MAPIDeleteMail, use MAPIFindNext to verify that the correct message will be deleted.

Argument

Explanation

Session

An opaque session handle whose value represents a session with the messaging system. The session handle is returned by MAPILogon and invalidated by MAPILogoff. If the value is 0 (zero), the messaging system establishes a session from a system default session (if one exists) or presents a log-in dialog box. In all cases, the messaging system returns to its state before the call.

UIParam

The parent window handle for the dialog box. A value of 0 (zero) specifies that any dialog box displayed is application modal.

MessageID$

The messaging system's string identifier for the message being deleted. The string identifier is returned by MAPIFindNext or MAPISaveMail. Applications should assume that this identifier
is invalid after MAPIDeleteMail returns successfully.

Flags

A bitmask of flags. All flags are reserved and should be set to
0 (zero).

Reserved

Reserved for future use. This argument must be 0 (zero).


The following table lists the possible return values of the MAPIDeleteMail function and their meanings.

Value

Name

Meaning

–2

MAPI_E_FAILURE

One or more unspecified errors occurred while deleting the mail. No mail was deleted.

–5

MAPI_E_INSUFFICIENT_MEMORY

There was insufficient memory to proceed. No mail was deleted.


Value

Name

Meaning

–17

MAPI_E_INVALID_MESSAGE

An invalid message ID was used for the MessageID$ argument. No mail was deleted.

–19

MAPI_E_INVALID_SESSION

An invalid session handle was used for the Session argument. No mail was deleted.

–1

MAPI_USER_ABORT

The user canceled the process. No mail was deleted.

0

SUCCESS_SUCCESS

The function returned successfully.


Examples

The following example finds and deletes the first message in the Inbox.


Sub MAIN
MAPI_LOGON_UI = 1
Session = MAPILogon(0, "", "", MAPI_LOGON_UI, 0)
Dim MessageID$
result = MAPIFindNext(Session, 0, "", "", 0, 0, MessageID$)
result = MAPIDeleteMail(Session, 0, MessageID$, 0, 0)
result = MAPILogoff(Session, 0, 0, 0)
End Sub

The following example saves a message in the Inbox, reads it, then deletes it. Use this example to determine the name of the current user.


Sub MAIN
MAPI_LOGON_UI = 1
Session = MAPILogon(0, "", "", MAPI_LOGON_UI, 0)
Dim MessageID$, UserName$, Address$
result = MAPISaveMail(Session, 0, "New Subject", "New Message",\
    0, 0, MessageID$)
result = MAPIReadMail(Session, 0, MessageID$, 0, 0)
result = MAPIQueryOriginator(UserName$, Address$)
result = MAPIDeleteMail(Session, 0, MessageID$, 0, 0)
result = MAPILogoff(Session, 0, 0, 0)
MsgBox "Current user: " + UserName$ + " @ " + Address$
End Sub