Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners -
https://partner.microsoft.com/global/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryserviceFor more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMSUsing the MailLogon Method
To properly use the
MailLogon method, specify a valid
Name argument. For example, if a mail profile called "Bob Kelly" exists on your computer, the following line of code is valid:
Application.MailLogon "Bob Kelly"
Using the MailLogon Method Improperly
If you do not specify a
Name argument in the
MailLogon command, the
Choose Profile dialog box may appear and request that you choose a mail profile. For example, if you use the following line of code
this may be a problem if you want to run the macro without supervision. If this is the case, specify a valid
Name argument.
If the
MailLogon command specifies an invalid
Name argument, for example, if you use the following line of code
Application.MailLogon "N. O. Body"
you may receive the following error message:
Microsoft Exchange
The profile name is not valid. Enter a valid profile name.
When you click
OK, the
Choose Profile dialog box is displayed.
If you click
Cancel in either the
Choose Profile dialog box or the error message dialog box, you receive the following
error message
Run-time error '1004':
Method 'MailLogon' of object '_Application' failed
and the macro halts.
Using the Password and DownloadNewMail Arguments
These arguments are optional. You need to include them only if your mail is
protected by a password or if you want to download new mail messages
immediately.
NOTE: The
Password argument is ignored if you are using Microsoft Exchange or Microsoft Outlook 2000.
Help Information for the MailLogon Method
The Microsoft Excel Visual Basic Help topic for the
MailLogon method states the following:
Name: Optional Variant. The mail account name of Microsoft Exchange profile name. If this argument is omitted, the default mail account name is used.
This statement is not entirely correct. If you omit the
Name argument from the
MailLogon method, the
Choose Profile dialog box may appear and request that you choose a mail profile.
For an example of the correct way to use the
MailLogon method, see the
MailLogon method example; the
Name,
Password, and
DownloadNewmail arguments are all present and valid.