Solved

Calling the default email editor

Posted on 1998-10-09
5
173 Views
Last Modified: 2010-04-30
How can you call a user's default email editor in VB 5/6 under Windows 95/98/NT?
0
Comment
Question by:mshire
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1439030

Debug.Print ExecuteWithAssociate(Me.hWnd, "mailto:", "waty.thierry@usa.net")

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpdirectory As String, ByVal nShowCmd As Long) As Long


Public Function ExecuteWithAssociate(ByVal hWnd As Long, S As String, Optional Param As Variant, Optional windowstyle As Variant) As Boolean
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 9/10/98
   ' * Time             : 11:48
   ' * Module Name      : Execute_Module
   ' * Module Filename  :Execute.bas
   ' * Procedure Name   : ExecuteWithAssociate
   ' * Parameters       :
   ' *                    ByVal hWnd As Long
   ' *                    S As String
   ' *                    Optional Param As Variant
   ' *                    Optional windowstyle As Variant
   ' **********************************************************************
   ' * Comments         :
   ' * Executes a file with it's associated program.
   ' *   windowstyle uses the same constants as the Shell function:
   ' *      vbHide   0
   ' *      vbNormalFocus  1
   ' *      vbMinimizedFocus  2
   ' *      vbMaximizedFocus  3
   ' *      vbNormalNoFocus   4
   ' *      vbMinimizedNoFocus   6
   ' *
   ' *  returns true on success
   ' *
   ' *
   ' **********************************************************************
   
   Dim i As Long

   If IsMissing(windowstyle) Then
      windowstyle = vbNormalFocus
   End If

   i = ShellExecute(hWnd, vbNullString, S, IIf(IsMissing(Param) Or (Param = ""), vbNullString, CStr(Param)), GetPath(S), CLng(windowstyle))
   If i > 32 Then
      ExecuteWithAssociate = True
   Else
      ExecuteWithAssociate = False
   End If
   
End Function


0
 

Author Comment

by:mshire
ID: 1439031
Thanks, I'll give it a go.
0
 

Author Comment

by:mshire
ID: 1439032
It calls the editor alright but it doesn't enter the email address parameter. Is there something I'm not doing or does it depend on the email editor (I'm using Outlook express)?

Thanks again.
0
 
LVL 14

Expert Comment

by:waty
ID: 1439033
try this :
Debug.Print ExecuteWithAssociate(Me.hWnd, "mailto:waty.thierry@usa.net")
0
 

Author Comment

by:mshire
ID: 1439034
Thats better, thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question