简体   繁体   English

C#VSTO Outlook 2016:修改图像中嵌入的超链接

[英]C# VSTO Outlook 2016: Modify hyperlink embedded in image

As part of a real time sentiment project, I have an outlook signature that is made up of a combination of happy, sad and neutral face, each of which has an embedded hyperlink associated to it (this is done within the signature functionality of Outlook). 作为实时情感项目的一部分,我有一个由快乐,悲伤和中立的表情组成的Outlook签名,每个表情都有与之关联的嵌入式超链接(这是在Outlook的签名功能内完成的) 。

Example "happy" hyperlink looks like this: http://xxxx/happy?sr=000000000 . 示例“快乐”超链接如下所示: http:// xxxx / happy?sr = 000000000

Using VSTO, I extract the real SR number in the email Subject and replace the "000000000" in the hyperlink with the SR number. 使用VSTO,我在电子邮件主题中提取了真实的SR号,并用SR号替换了超链接中的“ 000000000”。 I figured out how to extract the SR number from the subject using regex, but when I try to replace the "000000000" in mail.Body (mail.Body.Replace), it works but I lose the graphs (ie happy/sad/neutral faces). 我想出了如何使用正则表达式从主题中提取SR号,但是当我尝试替换mail.Body(mail.Body.Replace)中的“ 000000000”时,它起作用了,但是却丢失了图表(例如,happy / sad /中性面孔)。 So all I see in the email that gets sent are 3 hyperlinks. 因此,我在发送的电子邮件中仅看到3个超链接。

My code looks like this: 我的代码如下所示:

Regex regex = new Regex(@"(^|\D)(\d{9})($|\D)");
if (mail != null)
{
    Match m = regex.Match(mail.Subject);
    if (m.Success)
    {
         Group g = m.Groups[0];
         mail.Subject += " !!Found " + g + "  in subject.";
         mail.Body.Replace("000000000", g.ToString());
    }
    ...

I'm want to be able to pass the SR # in the hyperlink so that my web server can use it in the user feedback. 我希望能够在超链接中传递SR#,以便我的Web服务器可以在用户反馈中使用它。

My question is how can I replace the 000000000 in the hyperlinks without losing the graphical portion of my signature (happy, sad, neutral faces)? 我的问题是如何在不丢失签名的图形部分(开心,悲伤,中性的面孔)的情况下替换超链接中的000000000?

Thank you, Dan 谢谢丹

This newbie didn't realize C# didn't do in-place substitution :( 这个新手没有意识到C#没有做就地替换:(

mail.HTMLBody = mail.HTMLBody.Replace("000000000", g.ToString());

fixed the problem. 解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM