G
George Durzi
I have a datagrid with a select button in it. When the button is clicked, I
want to kick off a mailto: to email the datagrid row. The user would specify
the recipients, and hit Send himself.
Here's my code
string sBody = string.Concat(
"Entered by: ", dgNotes.SelectedItem.Cells[2].Text, @"\",
Environment.NewLine,
"(", dgNotes.SelectedItem.Cells[4].Text, ")", @"\", Environment.NewLine,
dgNotes.SelectedItem.Cells[5].Text, @"\", Environment.NewLine);
string sSubject = "Emailing Project Notes";
string sScript = string.Concat(@"window.open('mailto:?subject=",
sSubject, "&body=", sBody, "')");
StringBuilder sbEMNote = new StringBuilder();
sbEMNote.Append(@"<script language=javascript>");
sbEMNote.Append(sScript);
sbEMNote.Append(@"</script>");
if (!Page.IsStartupScriptRegistered("EmailIndividualNote"))
Page.RegisterStartupScript("EmailIndividualNote", sbEMNote.ToString());
An example of sScript was:
window.open('mailto:?subject=FMT - Emailing Project Notes&body=Entered by:
Durzi, George\\\r\n(7/2/2004 8:57:38 AM)\\\r\nTEST\\\r\n')
Works fine, except the carriage returns in the body were never displayed
properly. The body text that shows up in the message body is:
Entered by: Durzi, George(7/2/2004 8:57:38 AM)TEST
I had to escape the Environment.Newline otherwise I would get an
"unterminated string constant" javascript error.
Any idea how I can get the carriage return to show up properly in my message
body?
want to kick off a mailto: to email the datagrid row. The user would specify
the recipients, and hit Send himself.
Here's my code
string sBody = string.Concat(
"Entered by: ", dgNotes.SelectedItem.Cells[2].Text, @"\",
Environment.NewLine,
"(", dgNotes.SelectedItem.Cells[4].Text, ")", @"\", Environment.NewLine,
dgNotes.SelectedItem.Cells[5].Text, @"\", Environment.NewLine);
string sSubject = "Emailing Project Notes";
string sScript = string.Concat(@"window.open('mailto:?subject=",
sSubject, "&body=", sBody, "')");
StringBuilder sbEMNote = new StringBuilder();
sbEMNote.Append(@"<script language=javascript>");
sbEMNote.Append(sScript);
sbEMNote.Append(@"</script>");
if (!Page.IsStartupScriptRegistered("EmailIndividualNote"))
Page.RegisterStartupScript("EmailIndividualNote", sbEMNote.ToString());
An example of sScript was:
window.open('mailto:?subject=FMT - Emailing Project Notes&body=Entered by:
Durzi, George\\\r\n(7/2/2004 8:57:38 AM)\\\r\nTEST\\\r\n')
Works fine, except the carriage returns in the body were never displayed
properly. The body text that shows up in the message body is:
Entered by: Durzi, George(7/2/2004 8:57:38 AM)TEST
I had to escape the Environment.Newline otherwise I would get an
"unterminated string constant" javascript error.
Any idea how I can get the carriage return to show up properly in my message
body?