【问题标题】:Hyper link to email address电子邮件地址的超链接
【发布时间】:2013-08-03 13:59:38
【问题描述】:

我正在尝试使用此代码打开电子邮件客户端(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;
    }

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

【问题讨论】:

  • 使用“mailto:”而不是“http://”

标签: c# wpf email hyperlink


【解决方案1】:

使用mailto 链接:

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

【讨论】:

  • 这仅适用于默认电子邮件应用程序。如果您想使用 Gmail 或任何其他网络电子邮件提供商,则必须使用 System.Net.Mail 命名空间通过 SMTP 发送电子邮件。您可以单击超链接,处理导航,然后调用您的电子邮件功能...
猜你喜欢
  • 2015-01-12
  • 1970-01-01
  • 2011-05-14
  • 2013-11-25
  • 2011-10-01
  • 2011-05-20
  • 2011-06-11
  • 1970-01-01
相关资源
最近更新 更多