MAILTO: Link from a VB6 App

June 20, 2007 at 1:30 pm 6 comments

Well, hopefully I won’t be working in Visual Basic 6 enough to need to use this again.  But– just in case. 

I was working in an executable application written in Visual Basic 6.  I wanted a particular click to work just like a “MAILTO:” link does in a web browser.  Since I primarily work in web applications I knew exactly how to do it with the simpliest of HTML syntax, but wasn’t sure how to do it through an application. 

Turned out to be super easy– make a ShellExecute call with MAILTO:emailaddress as the filename.  In fact if you go to the Start->Run and type in MAILTO: and the email address, it will do the same thing– start an email to that individual.

Declaring ShellExecute Function

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

Using ShellExecute Function

filename=”email@company.com
stat = ShellExecute(0, “Open”, filename, vbNullString, vbNullString, 1)

P.S. Just like the MAILTO: link through HTML, you can define other parameters like subject lines and such.  I just needed email yesterday.

Entry filed under: MAILTO, ShellExecute, Uncategorized, Visual Basic 6.

Relay for Life 2007 List of Filenames from a Directory in Text Format

6 Comments Add your own

  • 1. Clint  |  June 20, 2007 at 2:39 pm

    but i want to mail with gmail, not outlook, you insensitive clod!

    🙂

    Reply
  • 2. Clint  |  June 20, 2007 at 2:39 pm

    (That was a joke y’know. the “insensitive clod” is a slashdot meme, you insensitive clod!)

    Reply
  • 3. tgaw  |  June 20, 2007 at 3:04 pm

    I was not aware of the slashdot reference, but your smiley face tipped me off that you were joking. Those blasted smilies can’t keep any secrets.

    Reply
  • 4. cap  |  August 2, 2007 at 8:56 am

    no funciona tu wea!!!

    Reply
  • 5. Adee  |  May 26, 2009 at 11:14 pm

    that’s what i need it
    thanx bro,.. i’ll try it at home

    Reply
  • 6. Warrior8  |  August 9, 2009 at 4:49 am

    It would be very nice if you explain the code so we won’t work like robots, meaning, understanding what exactly are we using.

    THANK YOU.

    Reply

Leave a comment

Trackback this post  |  Subscribe to the comments via RSS Feed


Flickr Photos

3D Printed Products