Using URL in C#
-
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
-
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
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 -
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
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 themailto:
protocol. There is no option to specify attachments in amailto:
link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
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
-
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 themailto:
protocol. There is no option to specify attachments in amailto:
link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer