garyjos
09-06-2003, 05:03 AM
Hello
I know in VB.Net there is a link you can insert for say an email address etc.
Can you do this in VB6, and how please?
Thanks
Gary.
Chris J Locke
09-06-2003, 05:18 AM
if you use the ShellExecute API, you can call the mailto command, which Windows will use to fire up the users' email client.Private Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function shellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal fsShowCmd As Long) As Long
Function gfn_shellExecute(DocName As String, Optional as_action As String) As Long
Dim Scr_hDC As Long
If as_action = "" Then as_action = "Open"
Scr_hDC = GetDesktopWindow()
gfn_shellExecute = shellExecute(Scr_hDC, as_action, DocName, "", "C:\", 1)
End FunctionShove that lot in a module, then in your program you just need to call the API:Private Sub Command1_Click()
Dim ll_result As Long
ll_result = gfn_shellExecute("mailto:chris@here.com")
End SubThe extra step would be to create a label with the email address as the caption, make it blue and underlined, then put the above code in the click event. You'd also have to change the icon as the user waves their mouse over it... theres not a standard 'hand' type icon though.
Easy, innit! ;)
garyjos
09-06-2003, 05:27 AM
Thanks Chris this is just what I want.
It will work on WIN95-XP COMPOUTERS?
How can I automatically fill in the Subject, and can you make it fixed?
Thanks Very Much
Gary.
Chris J Locke
09-06-2003, 05:40 AM
Its a standard Windows API, so should work on 95 and beyond.
There are several parameters for the mailto command. Do a Google search or check out Microsoft's explanation (http://msdn.microsoft.com/workshop/networking/predefined/mailto.asp) (yawn) which should explain what you can do. You can set the subject, to, CC and even lumps of the body text.
It does depend on the mail client though. I use Opera, and it doesn't like the body parameter, for example. Even a long subject line can cause it to cough. Better to stick with the to, and a small subject, just to make sure.