← servoy magazine

[Tip] Opening "mailto" link x-plat

  • Tips

Bob Cusick
Servoy USA

You can easily send email out of Servoy directly using the mail plug-in - without using the client's email program. However, there may be times that you DO want to use the client's email client to send the mail. The easiest way to do this is to use "application.openURL()" function and specify a "mailto" action. This is the same thing that the underlined email links do on web pages.

There is, however a difference in the way that Windows and Mac will accept the mailto. On the PC you can use this format: "Bob Cusick <bcusick@servoy.com>" and the "to" will show both the name of the person and not their mailing address. On the Mac - it won't accept the name of the person (or I haven't got it to work!) - so you need to use the email address only. Here's some sample code you can use in your own solutions:

if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
     application.showURL('mailto:' + first_name + " " + last_name + " <" + email_address + ">")
}
else
{
     application.showURL('mailto:' + email_address)
}

Comments (1)

Harjo Kompagnie
Hi Bob, there is one non-beauty issue with this method. Everytime you start this method on a client, there will be an extra Explorer-window kept open!