HOWTO: Using Visual Basic to Access the Mail Control Panel GUI

Last reviewed: November 21, 1997
Article ID: Q173552
The information in this article applies to:
  • Collaboration Data Objects (CDO), version 1.1
  • Microsoft Visual Basic Standard and Enterprise Editions for Windows, versions 4.0, 5.0

SUMMARY

For the sake of consistency, many developers like to provide the same configuration interfaces to their users as are provided in the Control Panel. These Control Panels are available for developers to call from their applications.

For Messaging related applications, the pertinent Control Panel applet is Mlcfg32.cpl. This article describes how to call this Control Panel applet from a Visual Basic Application.

MORE INFORMATION

  1. Place the following code sample into a new Visual Basic Form:

          Dim strSysDirPath As String
          Dim vRetval As Double
    

          Private Sub Form_Load()
    
             'Setup the string to receive the name of the system directory
             strSysDirPath = String$(145, Chr$(0))
             strSysDirPath = Left$(strSysDirPath, _
                             GetSystemDirectory(strSysDirPath, _
                             Len(strSysDirPath)))
    
             'Run the Mail Control Panel
             vRetval = Shell(strSysDirPath & "\control.exe mlcfg32.cpl", 1)
    
             'Do the rest of your work here. Note: Most developers will
             'likely want to pause their application here until returning from
             'the Control Panel
             MsgBox vRetval
    
          End Sub
    
    

  2. Place the following declaration into a new Module:

          Declare Function GetSystemDirectory& Lib "kernel32" _
    
             Alias "GetSystemDirectoryA" (ByVal P$, ByVal S%)
    
    

REFERENCES

For additional information about Collaboration Data Objects versus Active Messaging, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176916
   TITLE     : INFO: Active Messaging and Collaboration Data Objects (CDO)

Keywords          : kbcode ActMsg
Version           : WINDOWS:1.1,4.0,5.0
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.