none
SPUtility.SendEmail and Encoding issues RRS feed

  • Question

  • I think I'm missing something obvious on this one...

    I'd like to send the content of a field in a SharePoint list as an email (in a timer job)

    The regular view of the SharePoint list content that I'm trying to send as an email is:

    Three   spaces

    (The text is formatted as bold, and there are indeed three spaces between the words)

    The HTML view of the sharepoint list shows:

    <p><strong>Three&#160;&#160; spaces</strong></p>

    However, the email that is being received has the following:

    ThreeB B spaces

    Why are there "B"s in the mail message?

    The code that is sending the email is:

     SPUtility.SendEmail(rootWeb, true, false, "someemailaddress", "some subject", mailMessage);

    In the watch window, the value of mailMessage is displayed as:

    "<p><strong>Three   spaces</strong></p>\r\n"


    Mike G.

    Thursday, July 5, 2012 3:33 PM

All replies

  • Hi,

    First, please try to go to SharePoint Central Administration, outgoing email settings, check the character set of the settings, make sure it is set as expected.

    I’m not sure whether &nbsp is the same as &#160 in email body, please have a try to check whether the results are same.

    Thanks,


    Qiao Wei

    TechNet Community Support

    Friday, July 6, 2012 7:18 AM
    Moderator
  • In outgoing email settings, the character set is 65001. I have also tried the following:

    1. edit the html source of the list item
    2. replace all instances of &#160;  with &nbsp;
    3. click ok

    I get a message indicating that the html may have been modified. when I reopen the "edit html source" window, the &nbsp; entities have been replaced with &#160;

    If I replace the &#160; entities with just actual spaces and click ok, the extra spaces are removed. (Using &#160; for &nbsp; seems to be standard sharepoint behavior? I've tested the html view on a couple different servers, including an image built by MS, and they all use &#160;)

    When I view the HTML source of the email, it indeed has Bs, so it doesn't seem to be a client side encoding issue.


    Mike G.


    • Edited by m g Friday, July 6, 2012 1:05 PM punctuation
    Friday, July 6, 2012 1:05 PM