Share via


Application.MailLogoff Method

Project Developer Reference

Closes an established MAPI mail session.

Syntax

expression.MailLogoff

expression   A variable that represents an Application object.

Return Value
Nothing

Example
The following example checks for an existing mail session and logs off it. If not logged on, the following example logs on, downloads any new mail, and then logs off.

Visual Basic for Applications
  Sub LogoffFromMail()
If Not IsNull(MailSession) Then
    MsgBox "Logging off mail session: " & MailSession
    Application.<strong class="bterm">MailLogoff</strong>
Else
    MsgBox "Logging on to mail session now."
    Application.MailLogon DownloadNewMail:=True
    MsgBox "Logging off mail session: " &amp; MailSession
    Application.<strong class="bterm">MailLogoff</strong>
End If

End Sub

See Also