[RESOLVED] Space in FileName Link in an Email Body
I need to create a link to a file on a server in an e-mail body. We did this before but this time there is a space in the path for the target file. I cannot ask the client to change this as they have many other apps which look for this folder spelled with the space in its name. Okay so I am doing this:
I've been using System.Net.WebUtility.HtmlEncode to try and format this and it almost works but it substitutes %2520 for the %20....so I leave the %20 out and just use the space and it breaks the string at the space.
Last edited by Vladamir; Jan 8th, 2015 at 03:46 PM.
if you're getting %2520 then something is being double encoded the the %25 is the % ... all that should be urlencoded is just txtDwgNo.Text... nothing more, nothing less... and that should be that. Your space in "Customer Approval" part of the path has already been encoded, so don't re-do that... I don't think you need or should be using HTMLEncoded either.
Thanks techgnome. I finally found the code snippet that I did about a year ago with this and you're right that I need to be using UrlEncode....BUT! I can open the previous project and run it, test it, examine it just fine. But when I type this line into the new project, which BTW has all the same references, same Framework version 4.5, etc...
'UrlEncode' is not a member of 'System.Net.WebUtility'.
I'm sorry but this one has me. I don't see anything different from the other project compared to this one as far as it's environment, but I can't get past this error for the moment.
Oops! I found my trouble. The new project, which is actually an older one was using the Framework 4.5-Client, not the full version.
Last edited by Vladamir; Jan 8th, 2015 at 01:58 PM.
Okay, that resolved one issue with it. The space thing is still kicking my tail. I'm using the code above with the only exception that I enclose the long string in the UrlEncode method and I keep the space in "Customer Approval" part of the string. But as you can see from this screen shot, the problem with the space even shows up in the code. It's breaking the file path name on the space. And this darn forum interface keeps rescaling the image. I don't know if you can see or not but the blue color of the link only goes over until it hits that space character in the path name.
Last edited by Vladamir; Jan 8th, 2015 at 02:15 PM.
techgnome, sorry again, this may be where my version of VS 2013 Express for Desktop comes up against the wall. I don't have System.Web.HttpUtility...anything. In fact I only have ASPHosting.... choices in this version.
But when this runs I get a nice email with what looks like a working link in it, but the actual path for is is for C:\Users\MyName\AppData\...... in other words, it's not making the link point to the correct targeted folder on the server. This is GroupWise 8.x client we use and it's also a GroupWise MTA....which AFAIK works perfectly.
Last edited by Vladamir; Jan 8th, 2015 at 03:47 PM.
Lucky me, I got some advice from one of the web developers here and this is what it took to get it going. This is just the one line of the above code which needed correction.
Code:
"Click <a href='file://a_long_Novell_Path\Customer Approval\" & txtDwgNo.Text & ".dwg'>here</a> to open the drawing."
Turns out there was actually no need to do any encoding. It was the single quotes which made all the difference. I never was that good at punctuation.
Last edited by Vladamir; Jan 8th, 2015 at 04:11 PM.