HOWTO: send email without opening empty browser page

Hi,

I think I have a great tip for you all.
When you use this code in a Servoy Client on Windows:

application.showURL('mailto:info@servoy.com')

There was always opening that annoying empty browser-page!

I found a away to workaround this one:

make a global method and call it: mailto

var email = 'mailto:'
email += arguments[0]
if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
	application.executeProgram('rundll32', 'url.dll,FileProtocolHandler',email)
}
else application.showURL(email)

Now call the global method with:

globals.mailto('info@servoy.com')

The emailclient will open without the empty browser-page!
Have FUN!

Great Tip Harjo!!

Thanks very much!

Occasionally, when users try to send email from Windows machines, their default email client does not open.

The only thing that I can think is that something (e.g. a special character) in my email_string is causing windows to not open the default email client.

No errors are shown to the user. Nothing is logged on the server. When the debugger is turned on, it never complains, etc.

mailto-output.txt (5.33 KB)

mailto.txt (1.56 KB)

The problem seems to be that if the email_string is longer than 2037 characters, windows ignores the command.

This is on a Windows XP Service Pack 2.

Any ideas around this?

Thanks.

On your PC, goto My Computer, the Tools drop down, Folder Options, File Types tab, scroll down to htm and html. Do the File Types say URL:HyperText Transfer Protocol and HTML File or Internet Explorer or something else like FireFox?

If URL:HyperText Transfer Protocol doesn’t work, then try IE or even setting it to Outlook.

Worked for me.

Hi Harjo

Thanks for this tip! Have you got any idea how to avoid opening the default mail client on OS X without getting a browser window?

Regards, Robert

Hello!

Harjo’s tip to send an e-mail from Seervoy Smart Client with Mail by application.showURL(params) without opening a empty browser page unfortunately don’t work currently on Mac OS X (10.9, 10.10).

Is there a way to get this working only by opening the Mail form?

It would also be great to be able to attach PDF’s to the Mail send form.
Does anybody knows a solution to do that by the standard e-mail programs on Mac AND Windows?

Regards

Hi Thomas,

Back in 2006 OS might have reacted a little bit different.
Why don’t you create a form to build the email message, including pdf (file plugin with type filtering)
On submit you can send out the message using the mail plugin.

This solution works exactly the same for Mac/Windows and you’re even more flexible pre-populating addressees, subject, body
Using the ‘mailto’ tip might restrict you to a number of characters.

Hi Marc,

you are right, but customers would like to send their e-mails by the Mail program.
Of course I can always send a second e-mail to a seperate account to have organized all e-mails in the Mail program.
But it is more complex to make a solution for creating an e-mail with content incl. a PDF, to display it as preview and to execute sending like an e-mail program.

Regards

I think you could use AppleScript for this. Servoy can execute applescript (search the forum, several topics on that). I’m sure you can find many examples of sending email via AppleScript. So just tie those two together, and it should have what you need.

Thank you Scott,
I will give it a try.
I also will create a support ticket as feature request. Perhaps the Servoy guys take a look on it for an implementation.

Regards

tgs:
Of course I can always send a second e-mail to a seperate account to have organized all e-mails in the Mail program.

If your customers can work with IMAP of Exchange you can use the mailpro plugin / exchange plugin to achieve exactly that.

To get rid of the deprecation warning but the second and third parameter in an array:

application.executeProgram('rundll32', ['url.dll,FileProtocolHandler', email])

omar:
To get rid of the deprecation warning but the second and third parameter in an array:

application.executeProgram('rundll32', ['url.dll,FileProtocolHandler', email])

That’s right, but ‘MaiToProtocolHandler’ I think.