none
How to reset the body (message) of a mail item. RRS feed

  • Question

  • I'd like to have a reset button in the task pane reset (or set to blank) the message body of a mail message.

    When I use the following code, it just appends (or pre-pends) characters to the existing message body.

            // Insert into message body as plain text (CoercionType.Text)
    
            Office.context.mailbox.item.body.setSelectedDataAsync(
              StringToOutput,
              { coercionType: Office.CoercionType.Html },
              function (asyncResult) {
                  // Display the result to the user
                  if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
                      app.showNotification("Success", "Message inserted successfully.");
                  }
                  else {
                      app.showNotification("Error", "Failed to insert \"" + textToInsert + "\": " + asyncResult.error.message);
                  }
              });
    


    -- Ephraim

    Friday, February 10, 2017 5:37 PM

Answers

  • Use setAsync() method instead and set whatever you want.

    As the advise, please spend more time and discover Office.js API before ask a question ;)


    Slava Ivanov

    • Marked as answer by EphraimF Monday, February 13, 2017 9:15 PM
    Friday, February 10, 2017 6:17 PM

All replies

  • Use setAsync() method instead and set whatever you want.

    As the advise, please spend more time and discover Office.js API before ask a question ;)


    Slava Ivanov

    • Marked as answer by EphraimF Monday, February 13, 2017 9:15 PM
    Friday, February 10, 2017 6:17 PM
  • Thank you.

    I did not understand the difference between general JQuery and JavaScript syntax and the Office API.

    The documentation is really not very clear.

    Thanks to this forum, I have a much better handle on it now.


    -- Ephraim


    • Edited by EphraimF Monday, February 13, 2017 9:17 PM
    Monday, February 13, 2017 9:16 PM
  • Glad to hear, Ephraim!

    Best regards,


    Slava Ivanov

    Monday, February 13, 2017 9:19 PM