Mailto: not working as expected, and a solution
Posted by Theo Heselmans on August 31st, 2008
I got this new customer that never had Lotus Notes before, but after seeing a demo, were convinced that I could write them an application, to good to be true. Which I did ;-)
Problem is that they want to keep on using Outlook for their mail client. Too bad: their loss, but my pain.
I built into most apps I develop means of creating a pre-filled email on the fly. Naturally, you create a maildoc in the users mail file, and off you go. Not this time however.
I had this brilliant idea: notesuiworkspace.UrlOpen opens a url based on the protocol:
- http:// opens a browser;
- notes:// opens a notes document/view/database;
- mailto: would open an email !!
Weird, isn't it. It looks like Notes interpretes the URL passed to it, and seeing it's mailto: handles it itself, instead of passing it to the OS.
Damn. I was so proud of my simple solution (as mailto: has a rather flexible syntax).
I finally resorted to a solution I found over at DominoPower:
Different ways to programmatically create an email message.
It's a call to the windows api:
%INCLUDE "lsconst.lss"
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
Dim taskid As Long
Dim ingReturn As Long
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
Dim taskid As Long
Dim ingReturn As Long
The executable Lotus Script code is :
Sub MailTo(allAddr as string)
taskid = Getthreadinfo(LSI_THREAD_TASK_ID)
ingReturn = ShellExecute(taskid, "Open", "mailto:" + allAddr, "", "", 1)
end Sub
taskid = Getthreadinfo(LSI_THREAD_TASK_ID)
ingReturn = ShellExecute(taskid, "Open", "mailto:" + allAddr, "", "", 1)
end Sub
It does work, but it's no longer cross platform, nor elegant.
You got a better idea ?
Category: Show-n-Tell Thursday SnTT | Technorati: Show-n-Tell Thursday, SnTT
Comments (3)
Could it be in the way you do it? My memory is hazy, but I'm sure I've done something like this using hotspots rather than the NotesUIWorkspace class, and that this code *did* defer to the registered mail handler on the system.
Could you programatically create a hotspot instead?
@Ben, I tried with @URLOpen, but got the same result: a new notes email. (BTW I used 7.03)
I faced the same issue. I found a more elegant solution at { Link }
Change the url hotspot to an action hotspot with following code
@Command ([Execute];"mailto:john.doe@acme.com")
This launches the default mail client that was configured for the OS.
I tested on Notes 9/Windows 8.
I assume it also works on other platforms.