Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Using the MailLogon Method in Microsoft Excel 2000


View products that this article applies to.

This article was previously published under Q211794

↑ Back to the top


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.

↑ Back to the top


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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For 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;CNTACTMS

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.

↑ Back to the top


Keywords: KB211794, kbhowto, kberrmsg

↑ Back to the top

Article Info
Article ID : 211794
Revision : 7
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 297