0

我尝试使用此代码打开电子邮件客户端(Outlook 或 Gmail,具体取决于用户偏好)。

XAML:

    <TextBlock  Margin="0,5,0,0"  >
         <Hyperlink  RequestNavigate="HandleRequestNavigate" Foreground="{StaticResource EnableColorSolid}" NavigateUri="http://info@kramerel.com">
                   info@kramerel.com
         </Hyperlink>
    </TextBlock>

代码:

 private void HandleRequestNavigate(object sender, RequestNavigateEventArgs e)
    {
        string navigateUri = (sender as Hyperlink).NavigateUri.ToString();
        // if the URI somehow came from an untrusted source, make sure to
        // validate it before calling Process.Start(), e.g. check to see
        // the scheme is HTTP, etc.
        Process.Start(new ProcessStartInfo(navigateUri));
        e.Handled = true;
    }

但它不起作用。知道为什么吗?我认为链接有问题,但我不知道它是什么。

4

1 回答 1

0

使用mailto链接:

<TextBlock  Margin="0,5,0,0"  >
         <Hyperlink  RequestNavigate="HandleRequestNavigate" 
          Foreground="{StaticResource EnableColorSolid}" 
          NavigateUri="mailto:info@kramerel.com">
                   info@kramerel.com
         </Hyperlink>
</TextBlock>
于 2013-08-02T10:22:24.867 回答