Solved

Calling the default email editor

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now