0 votes

Any chance to redirect links from displayed HTML in MailBrowser component to default browser?

Now, when I display email message in this component (displayed correctly) and message contains external link, after clicking on this link referred web page is traying display in MailBrowser. And almost every time with some error - scripts error, recommendation to update browser and so on...
Or disable this external links, but this is not prefered...

Another odd behavior - when I click to MailBrowser (somewhere, no links), components catch focus and no chance to release him. Clicking to another component - treeview/listview imediately lost focus back to mailbrowser...

by (300 points)

1 Answer

0 votes

MailBrowser inherits from a standard WebBrowser control. Any solution for WebBrowser should also work with MailBrowser.

MailBrowserControl c = new MailBrowserControl();
c.Navigating += (sender, e) =>
{
    if (e.Url.Scheme == "https"
        || e.Url.Scheme == "http")
    {
        string url = e.Url.ToString();
        Process.Start(new ProcessStartInfo(url)
        {
            UseShellExecute = true
        });
        e.Cancel = true;
    }
};
by (297k points)
edited by
Help with adding MailBrowser component to project
...