c# - Pass URL with single quote and ampersand in Outlook using a .NET website -


i have web page uses webmail service send emails. on company intranet using microsoft exchange server. website created email link image handler on website. in code, can print debug messages , see:

<img src='http://tav.target.com/vibehandler.ashx?id=z064441_45975&type=amazing'/> 

but in email, when view source code, see this:

<img src="http://tav.target.com/vibehandler.ashx?id=z064441_45975&amp;type=amazing"/> 

my single quotes changed double quotes (no big deal).

& 

changed

&amp; 

this causes url not work , images appear red "x", indicating missing image.

how can preserve url?

your 3rd party emailing service might converting html document valid xml document compatibility reasons.

http://en.wikipedia.org/wiki/list_of_xml_and_html_character_entity_references

basically, in xml, ampersand character represents , xml entity, , can not used unless place text within cdata node. 3rd party service seems converting & &amp; , work safely display value, doesn't url.

http://www.w3schools.com/xml/xml_cdata.asp

if in situation, url encode image url when generating html document being sent out. way, both proper link, , valid xml string.

httputility.urlencode(myurlstring); 

http://msdn.microsoft.com/en-us/library/4fkewx0t%28v=vs.110%29.aspx

hope helps!


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -