locked
The method prependAsync from JavaScript API for Office inserts a text in at the bottom of the body (Only in OWA) RRS feed

  • Question

  • The prependAsync method inserts the specified string at the beginning of the item body. Calling the prependAsync method is the same as calling the setSelectedDataAsync method with the insertion point at the beginning of the body content.

    Environment:

    OWA (office.com)

    My code:

     item.body.prependAsync(
                            text,
                            {
                                coercionType: Office.CoercionType.Text
                            },
                            function (async) {
                                if (app.getAsyncResult(async)) {
                                    callback();
                                }
                            });
    

    Result:

    The text added in bottom of the body.

    But it works well in the Desktop version of Outlook or for Html.

    Wednesday, September 7, 2016 10:27 AM

Answers

  • Hello Antony,

    I have tried your original scenario and able to confirm the method "prependAsync" doesn't work properly when composing message in text format in Outlook for Web. The following is my result ...

    Prepend HTML text "<i>--- text to prepend ---</i>" in Outlook 2016 desktop:

    Prepend the same HTML when composing in Outlook for Web:

    As you may notice there is already difference in the rendering; for Web Otlook adds new line automatically.

    Prepend TEXT "--- text to prepend ---\n--- text to prepend ---" in Outlook 2016 desktop:

    And finally prepend the same text in Outlook for Web:

    The last test case fail as you discovered. Should be fixed by Office team indeed, but meanwhile I have tried work around. I used the "getAsync" and "setAsync" functions which unfortunately available only in API level 1.3 and get it working with the same text message. The following is my test code:

                        Office.context.mailbox.item.body.getAsync(
                            Office.CoercionType.Text,
                            {},
                            function (async) {
                                var body = async.value;
                                body = "--- text to prepend ---\n--- text to prepend ---" + body;
                                Office.context.mailbox.item.body.setAsync(
                                     body,
                            {
                                coercionType: Office.CoercionType.Text
                            },
                            function (async) {
                                var i = 0;
                            }
    
                                );
                            });
    

    And result looks the same for Outlook for Web and Outlook 2016:

    I hope this helps and somebody from moderators able to promote the issue to Office dev team. You may also open "Incident report" with Microsoft directly. I would probably do that for you under our MSDN subscription, but I do not require this feature in our app and already waiting for 2 month on my own issues with "saveAsync" on desktop. They are moving slow ;) 


    Slava Ivanov

    Wednesday, September 7, 2016 3:31 PM

All replies

  • Hello Antony,

    I have tried your original scenario and able to confirm the method "prependAsync" doesn't work properly when composing message in text format in Outlook for Web. The following is my result ...

    Prepend HTML text "<i>--- text to prepend ---</i>" in Outlook 2016 desktop:

    Prepend the same HTML when composing in Outlook for Web:

    As you may notice there is already difference in the rendering; for Web Otlook adds new line automatically.

    Prepend TEXT "--- text to prepend ---\n--- text to prepend ---" in Outlook 2016 desktop:

    And finally prepend the same text in Outlook for Web:

    The last test case fail as you discovered. Should be fixed by Office team indeed, but meanwhile I have tried work around. I used the "getAsync" and "setAsync" functions which unfortunately available only in API level 1.3 and get it working with the same text message. The following is my test code:

                        Office.context.mailbox.item.body.getAsync(
                            Office.CoercionType.Text,
                            {},
                            function (async) {
                                var body = async.value;
                                body = "--- text to prepend ---\n--- text to prepend ---" + body;
                                Office.context.mailbox.item.body.setAsync(
                                     body,
                            {
                                coercionType: Office.CoercionType.Text
                            },
                            function (async) {
                                var i = 0;
                            }
    
                                );
                            });
    

    And result looks the same for Outlook for Web and Outlook 2016:

    I hope this helps and somebody from moderators able to promote the issue to Office dev team. You may also open "Incident report" with Microsoft directly. I would probably do that for you under our MSDN subscription, but I do not require this feature in our app and already waiting for 2 month on my own issues with "saveAsync" on desktop. They are moving slow ;) 


    Slava Ivanov

    Wednesday, September 7, 2016 3:31 PM
  • Hi Antony Novitsky,

    For this issue you can try to give feedback to Outlook User Voice.

    please visit the link below to submit your feedback.

    Outlook User Voice

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 8, 2016 8:18 AM