Library code snippets

Email Link

Ever wanted to provide an email link in your application to enable your users to contact you, without wanting the complexity of integrating full email support? Just use ShellExecute with this very simple example! All you need to do is use the code below and call OpenEmail (sEmail) where sEmail is the email address.

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

Private Sub OpenEmail(sEmail)
    ' Mail the email address using
    ' the default email client
    ShellExecute 0, vbNullString, "mailto:" & sEmail, vbNullString, vbNullString, vbNormalFocus
End Sub

Comments

  1. 28 Sep 2005 at 20:42

    i got

    Quote:

    compile error:
    Sub or function not defined


    any idea what that is?

  2. 27 Jul 2004 at 15:13

    Yes u can, and more over u can send all the details of the mail.
    Just follow this;


    Dim sDest, sSubject, sBody, sCC, sBCC As String


    Call ShellExecute 0, vbNullString, "mailto:" & sDest & "?subject=" & sSubject & _
           "&body=" & sBody & "&CC=" & sCC & "&BCC=" & sBCC, _
           vbNullString, vbNullString, vbNormalFocus


    'And of course substitute the string variables with the values u want.


    Make it and it will work........

  3. 27 Jul 2004 at 01:59

    Right...


    Thanx!

  4. 26 Jul 2004 at 10:36

    Type Call before calling the function

  5. 25 Jul 2004 at 04:16

    Doesn't work for me ( I get a syntax error in the line with shelexecute(...) - VB6 says it expects "=" in that line (?)


    Can anyone help, please?

  6. 08 Sep 2002 at 21:42

    can I put the message and send automatic?

  7. 01 Jan 1999 at 00:00

    This thread is for discussions of Email Link.

Leave a comment

Sign in or Join us (it's free).