Applies To
Application Object.
Description
Logs into MAPI Mail or Microsoft Exchange and establishes a mail session. If Microsoft Mail is not already running, you must use this method to establish a mail session before mail or document routing functions can be used.
Syntax
object.MailLogon(name, password, downloadNewMail)
object
Required. The Application object.
name
Optional. The mail account name or Microsoft Exchange profile name. If omitted, the default mail account name is used.
password
Optional. The mail account password. This argument is ignored in Microsoft Exchange.
downloadNewMail
Optional. If True, new mail is downloaded immediately.
Remarks
Mail sessions previously established by Microsoft Excel are logged off before an attempt is made to establish the new session.
Omit both the name and password parameters to piggyback on the system default mail session.
See Also
MailLogoff Method, MailSession Property, SendMail Method.
Example
This example logs into mail and downloads any new mail immediately.
If IsNull(Application.MailSession) Then Application.MailLogon "oscarx", "mypassword", True End If