Results 1 to 8 of 8

Thread: [RESOLVED] Space in FileName Link in an Email Body

  1. #1

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Resolved [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:
    Code:
    Mailmsg.Body = "<html><head><title></title><body>" & _
         Environment.UserName & " submitted a drawing checklist on " & Today & " at " & TimeOfDay & "." & "<br> <br>" & _
        "Drawing No:" & Chr(9) & txtDwgNo.Text & "<br>" & _
        "Product Type:" & Chr(9) & txtProductType.Text & "<br>" & _
        "Model:" & Chr(9) & Chr(9) & txtModel.Text & "<br>" & _
        "Notes:" & Chr(9) & Chr(9) & Notes.Text & "<br> <br>" & _
        "Click <a href=file://\\a_long_Novell_Path\Customer%20Approval\" & txtDwgNo.Text & ".dwg" & "> here </a> to open the drawing:<br><br></body></html>"
    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.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Space in FileName Link in an Email Body

    IT needs to be URLEncoded, not HTMLEncoded.

    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.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Re: Space in FileName Link in an Email Body

    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...
    Code:
    Mailmsg.Body = System.Net.WebUtility.UrlEncode(xyz)
    I get
    '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.

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Space in FileName Link in an Email Body

    Try System.Web.HttpUtility.URLEncode

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Re: Space in FileName Link in an Email Body

    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.
    Attached Images Attached Images  
    Last edited by Vladamir; Jan 8th, 2015 at 02:15 PM.

  6. #6

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Re: Space in FileName Link in an Email Body

    Quote Originally Posted by techgnome View Post
    Try System.Web.HttpUtility.URLEncode

    -tg
    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.

  7. #7

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Re: Space in FileName Link in an Email Body

    I have a little more progress on this. At least it looks like progress
    Code:
    Mailmsg.Body = "<html><head><title></title></head><body>" & _
                    Environment.UserName & " submitted a drawing checklist on " & Today & " at " & TimeOfDay & "." & "<br> <br>" & _
                    "Drawing No:" & Chr(9) & txtDwgNo.Text & "<br>" & _
                    "Product Type:" & Chr(9) & txtProductType.Text & "<br>" & _
                    "Model:" & Chr(9) & Chr(9) & txtModel.Text & "<br>" & _
                    "Notes:" & Chr(9) & Chr(9) & Notes.Text & "<br> <br>" & _
                    "Click <a href=" & System.Net.WebUtility.UrlEncode("file://\\a_long_Novell_Path\Customer Approval\" & txtDwgNo.Text) & ".dwg" & _
                    "> here </a> to open the drawing.<br<br></body></html>"
                obj.Send(Mailmsg)
    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.

  8. #8

    Thread Starter
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 2012
    Location
    Miami, FL
    Posts
    486

    Re: Space in FileName Link in an Email Body

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width