Note that there are some explanatory texts on larger screens.

plurals
  1. POLinebreaks not displaying in email sent to Outlook via Sharepoint
    primarykey
    data
    text
    <p>I'm trying to set up a temporary Sharepoint page that presents a form where users can enter some text and have it emailed off. So I have a page containing a form and a submit button that calls some JS to put the entered text into a SOAP request for Sharepoint, which adds it to a list and then sends an email containing that information. So far so good, and pretty painless.</p> <p>The issue I'm having is that Outlook ignores any linebreaks that are part of the entered text. They're not being stripped out by anything, since I can use the 'View Source' option and see them normally in Notepad. I figure this is because Outlook's trying to display the message as HTML and doesn't know what to do with them. Ordinarily, I'd just throw in some JS that replaces all instances of <code>\r\n</code> with <code>&lt;br /&gt;</code> tags, but putting that into the SOAP request just results in anything following the tag being cut off before it gets added to the Sharepoint list.</p> <p>Other things I've tried are</p> <ul> <li>Adding a pair of spaces at the start of each new line (no change)</li> <li>Added a second set of <code>\r\n</code> to every linebreak (no change)</li> <li>Replaced all instances of <code>\r\n</code> with <code>%0D%0A</code> (displayed as text)</li> <li>Replaced all instances of <code>\r\n</code> with <code>\par</code> (actually used <code>\\par</code>, to escape the first backslash). (displayed as text)</li> <li>Appended <code>\t</code> to all instances of <code>\r\n</code>. (no change)</li> <li>Prepended '.' to all instances of <code>\r\n</code>. (periods displayed, but linebreaks did not)</li> </ul> <p>I'm working with Outlook 2007, Sharepoint 2007, and Internet Explorer 8.</p> <p>I've read the questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/9739354/javascript-email-linebreaks">javascript email linebreaks</a></li> <li><a href="https://stackoverflow.com/questions/136052/how-do-i-format-a-string-in-an-email-so-outlook-will-print-the-line-breaks">How do I format a string in an email so Outlook will print the line breaks?</a></li> <li><a href="https://stackoverflow.com/questions/4768118/how-to-break-line-in-javascript">How to break line in Javascript</a></li> <li><a href="https://stackoverflow.com/questions/247546/outlook-autocleaning-my-line-breaks-and-screwing-up-my-email-format">Outlook autocleaning my line breaks and screwing up my email format</a></li> </ul> <p>This is the JS function I'm working with to edit the text, as well as create and POST the SOAP request. It's currently set up to place periods before each linebreak:</p> <pre><code> function createAndPostSOAP(siteURL, listName) { var moreText = $("#MoreText")[0].innerText; var linebreakCount = moreText.match(/\r\n/g); moreText= " " + moreText; for (var count = linebreakCount.length; count &gt;= 0; count--) { moreText = moreText.replace("\r\n", ".[replace]"); } while(moreText.indexOf("[replace]") != -1) { moreText = moreText.replace("[replace]", "\r\n"); } var batch = "&lt;Batch OnError='Continue'&gt; \ &lt;Method ID='1' Cmd='New'&gt; \ &lt;Field Name='Text'&gt;" + $("Text")[0].value + "&lt;/Field&gt; \ &lt;Field Name='MoreText'&gt;" + moreText + "&lt;/Field&gt; \ &lt;/Method&gt; \ &lt;/Batch&gt;"; var soapEnv = "&lt;?xml version='1.0' encoding='utf-8'?&gt; \ &lt;soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' \ xmlns:xsd='http://www.w3.org/2001/XMLSchema' \ xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'&gt; \ &lt;soap:Body&gt; \ &lt;UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'&gt; \ &lt;listName&gt;" + listName + "&lt;/listName&gt; \ &lt;updates&gt; \ " + batch + "&lt;/updates&gt; \ &lt;/UpdateListItems&gt; \ &lt;/soap:Body&gt; \ &lt;/soap:Envelope&gt;"; $.ajax({ url: siteURL + "/_vti_bin/lists.asmx", beforeSend: function(xhr) { xhr.setRequestHeader ("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"); }, type: "POST", dataType: "xml", data: soapEnv, contentType: "text/xml; charset=utf-8" }); window.location='starting_page.htm'; } </code></pre> <p>I'm mostly attacking this from the Javascript end, because I know that better than Sharepoint, but is there a way in Sharepoint 2007 to have a script change the linebreaks into <code>&lt;br /&gt;</code> once the data is already added to the column? Or is there an angle I missed in the Javascript?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload