Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Using URL in C#

Using URL in C#

Scheduled Pinned Locked Moved C#
helpquestioncsharpcssregex
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    annex45
    wrote on last edited by
    #1

    Hello all! I have a couple of questions, half C# related, the other half, less C# related, but more related to embedding URL in C#, thank you for your attention. I'm writing a console app (in C#) that is supposed to pop up the default mail software, fill in the recipients, subject and body. this data is acquired from a txt file the app processed. To do that I start a process (IEXPLORE) and give it the @"mailto:...", A regex I created from the processed data. problem is, the body of the text does not take \n seriously and well, basically I have one long line where five should be. one of my questions is, how do I get a URL to produce a line break? A second issue is that the app is also supposed to attach the attachments, whose full local path has been processed from the latter mentioned txt file. i used the &attachments="c:\..." and well, no attachments.. Now for the more C# related part... the app has two bi-products : It opens a console windows which needs to be manually closed IT opens an explorer window that needs to be manually closed I am a novice programmer and still do not know much about threads.. I understand that I will have to use them somehow, could someone point me in the right direction? Thank you in advance

    P Richard DeemingR J 3 Replies Last reply
    0
    • A annex45

      Hello all! I have a couple of questions, half C# related, the other half, less C# related, but more related to embedding URL in C#, thank you for your attention. I'm writing a console app (in C#) that is supposed to pop up the default mail software, fill in the recipients, subject and body. this data is acquired from a txt file the app processed. To do that I start a process (IEXPLORE) and give it the @"mailto:...", A regex I created from the processed data. problem is, the body of the text does not take \n seriously and well, basically I have one long line where five should be. one of my questions is, how do I get a URL to produce a line break? A second issue is that the app is also supposed to attach the attachments, whose full local path has been processed from the latter mentioned txt file. i used the &attachments="c:\..." and well, no attachments.. Now for the more C# related part... the app has two bi-products : It opens a console windows which needs to be manually closed IT opens an explorer window that needs to be manually closed I am a novice programmer and still do not know much about threads.. I understand that I will have to use them somehow, could someone point me in the right direction? Thank you in advance

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      annex45 wrote:

      how do I get a URL to produce a line break

      You don't. A URL is a continuous sequence of characters, and should remain so - plus, if you could break the line, where would you break it? Just because it fills a line of text on your monitor doesn't mean that it won't wrap when viewed on a tiny screen smartphone. Now, as for threading, a simple way to spawn off your work is to use the Tasks Parallel Library (TPL). This[^] is a great place to get started.

      I was brought up to respect my elders. I don't respect many people nowadays.
      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      1 Reply Last reply
      0
      • A annex45

        Hello all! I have a couple of questions, half C# related, the other half, less C# related, but more related to embedding URL in C#, thank you for your attention. I'm writing a console app (in C#) that is supposed to pop up the default mail software, fill in the recipients, subject and body. this data is acquired from a txt file the app processed. To do that I start a process (IEXPLORE) and give it the @"mailto:...", A regex I created from the processed data. problem is, the body of the text does not take \n seriously and well, basically I have one long line where five should be. one of my questions is, how do I get a URL to produce a line break? A second issue is that the app is also supposed to attach the attachments, whose full local path has been processed from the latter mentioned txt file. i used the &attachments="c:\..." and well, no attachments.. Now for the more C# related part... the app has two bi-products : It opens a console windows which needs to be manually closed IT opens an explorer window that needs to be manually closed I am a novice programmer and still do not know much about threads.. I understand that I will have to use them somehow, could someone point me in the right direction? Thank you in advance

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        To add a line break, you need to encode it using %0A:

        mailto:test@test.org?subject=Hello&body=Line 1**%0ALine 2%0A**Line 3

        [Example](mailto:test@test.org?subject=Hello&body=Line 1%0ALine 2%0ALine 3) The simplest way to encode the data is to use the Uri.EscapeDataString method[^]:

        string url = "mailto:test@test.org?subject=" + Uri.EscapeDataString(subject) + "&body=" + Uri.EscapeDataString(body);

        You don't need to launch Internet Explorer to open the URL. Just use Process.Start("mailto:...") to open the registered handler for the mailto: protocol. There is no option to specify attachments in a mailto: link.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        A 1 Reply Last reply
        0
        • A annex45

          Hello all! I have a couple of questions, half C# related, the other half, less C# related, but more related to embedding URL in C#, thank you for your attention. I'm writing a console app (in C#) that is supposed to pop up the default mail software, fill in the recipients, subject and body. this data is acquired from a txt file the app processed. To do that I start a process (IEXPLORE) and give it the @"mailto:...", A regex I created from the processed data. problem is, the body of the text does not take \n seriously and well, basically I have one long line where five should be. one of my questions is, how do I get a URL to produce a line break? A second issue is that the app is also supposed to attach the attachments, whose full local path has been processed from the latter mentioned txt file. i used the &attachments="c:\..." and well, no attachments.. Now for the more C# related part... the app has two bi-products : It opens a console windows which needs to be manually closed IT opens an explorer window that needs to be manually closed I am a novice programmer and still do not know much about threads.. I understand that I will have to use them somehow, could someone point me in the right direction? Thank you in advance

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          annex45 wrote:

          I'm writing a console app (in C#) that is supposed to pop up the default mail software,

          I find that requirement a bit odd.

          1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            To add a line break, you need to encode it using %0A:

            mailto:test@test.org?subject=Hello&body=Line 1**%0ALine 2%0A**Line 3

            [Example](mailto:test@test.org?subject=Hello&body=Line 1%0ALine 2%0ALine 3) The simplest way to encode the data is to use the Uri.EscapeDataString method[^]:

            string url = "mailto:test@test.org?subject=" + Uri.EscapeDataString(subject) + "&body=" + Uri.EscapeDataString(body);

            You don't need to launch Internet Explorer to open the URL. Just use Process.Start("mailto:...") to open the registered handler for the mailto: protocol. There is no option to specify attachments in a mailto: link.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            A Offline
            A Offline
            annex45
            wrote on last edited by
            #5

            Thank you so much!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups