HTMLViewer - follow maito: - link

Dear Forum,

I use an HTMViewer control in order to display a html file which contains a mailto: - link.
If I open that html file in any browser, clicking von that mailto:-link opens the standard eMail client, using the eAMil address speified in the mailto-link.


Using the html viewer control, the behaviour is not as expected.

  • under OS X, nothing happens
  • under Windows, the following error message is displayed: “Error -302 when loading

Any hints or ideas?

Look into the CancelLoad and NewWindow events.

In those, you might create a temporary file and launch that to achieve the same effect. (Need the same for a popup or new window effect)

Its a mistake to think the HTMLViewer is Safari or Chrome

The simplest way to go is in the CancelLoad event when mailto: is in the URL, and simply ShowURL the url in question and return True. The system will then open the default mail client, as it does in regular browsers.

Make sure you return True in this case to tell the viewer that you handled it.

Thank you all for your efforts and attempts to help me!
Michel, indeed I had to put the following code in the CancelLoad event:

If URL.StartsWith("mailto:") Then ShowURL URL Return True End If

That does the magic…

By the way:
the function StartsWith is an extension to my string class:

[code]Function StartsWith(Extends srcString as String, search as string) As Boolean
If srcString = “” Then Return False
If search = “” Then Return False

Dim anz As Int32 = search.Len

If anz > srcString.Len Then Return False

If Left(srcstring, anz) = search Then
Return True
Return False
End If
End Function[/code]

I’m sure Kem has a pile of these in his M_String module