Answered by:
Outlook adds <span style='color:blue'> to HTML links in outgoing HTML emails

Question
-
I am creating an Outlook add-in using C# that searches for a link in an HTML (new) email body signature when a user clicks on Send button in Outlook email. I am hooking into Application_ItemSend event. What's odd is that on my machine running XP/Outlook 2007 and in another Win7/Outlook 2007 machine, I am able to search for the link in the signature with no problems. But on some other Win7/Outlook 2007 machine, I am not able to search for the link because an additional span element is being inserted by Outlook.
For example, I am searching for
<a href="http://www.google.com">
Link</a>
in an HTML (new) email body. The link above is being inserted by a default signature so I am expecting to find it all the time. On some machines I am able to, on some machines I am not able to because the link appears like this:<a href="http://www.google.com"><span style='color:blue'>
Link</span></a>
I've rolled out a standard signature html file so the signatures for all machines are the same, but the issue still persists. I am still in the process of comparing the font/theme settings, but so far have seen no difference.Does anyone have an idea on what's happening here?
Thanks.
Thursday, November 8, 2012 5:02 PM
Answers
-
Hi developer4x,
Thanks for posting in the MSDN Forum.
The first idea of mine is your issue can be handle via text regular expressions.
please try following pattern in regular expression: <a href="http://www.google.com">[\S \s]*Link[\S \s]*</a> in your program.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by 许阳(无锡) Tuesday, November 13, 2012 6:52 AM
- Marked as answer by Quist Zhang Monday, December 10, 2012 5:27 AM
Friday, November 9, 2012 6:09 AM
All replies
-
To add more context, the goal of the add-in is to replace a text (in this case, a link) in an outgoing mail signature with another set of text (in this case another link, with some images). So the original link in the signature acts as a token that needs to be replaced. I don't see how parsing makes any difference. Unless I'm completely missing something obvious. ThanksThursday, November 8, 2012 5:02 PM
-
try to use mailItem.GetInspector.WordEditor and case it to Word Document interface. There you can access its Hyperlinks collection and do your replacement.Thursday, November 8, 2012 7:50 PM
-
Hi developer4x,
Thanks for posting in the MSDN Forum.
The first idea of mine is your issue can be handle via text regular expressions.
please try following pattern in regular expression: <a href="http://www.google.com">[\S \s]*Link[\S \s]*</a> in your program.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by 许阳(无锡) Tuesday, November 13, 2012 6:52 AM
- Marked as answer by Quist Zhang Monday, December 10, 2012 5:27 AM
Friday, November 9, 2012 6:09 AM