Solved

Calling the default email editor

Posted on 1998-10-09
5
159 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 97
Put text in a picture ASP.NET C# 2 58
VBA Shell can't Find Word document 11 95
Advice in Xamarin 21 80
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

831 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