XL2000: Using the MailLogon Method in Microsoft Excel 2000 (211794)



The information in this article applies to:

  • Microsoft Excel 2000

This article was previously published under Q211794

SUMMARY

This article describes the correct way to use the Visual Basic for Applications MailLogon method in Microsoft Excel 2000. It also lists possible problems that you may encounter when you use this method to establish a mail session in Microsoft Excel 2000.

MORE INFORMATION

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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

Using 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
Application.MailLogon
				
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.

Modification Type:MajorLast Reviewed:11/5/2003
Keywords:kberrmsg kbhowto KB211794