none
Modify HTMLBody Inline Response. Flickering effect RRS feed

  • Question

  • I'm working on an Outlook Addin that adds or replace a text from html body from email when is opened to edit.

    I attached to Explorer.InlineResponse a function to manage this action.

    The problem is that when the mailItem.HTMLBody property is set (when email is shown in Reading Pane) window makes and unpleasant flickering at its opening.

    Exists a event handler previous to Explorer.InlineResponse- before email text is displayed- that avoid this effect?

    I don't know if I'm clear enough.

    Any advise or direction would be highly appreciated.

    Thank You.

    Thursday, November 2, 2017 11:38 AM

All replies

  • Hello,

    Where did you get a mail item instance? Does it come from the InlineResponse  event handler parameters?

    Try using Explorer.SelectionChange. It is fired when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface.

    Also you may find the MailItem.Reply event helpful. It is fired when the user selects the Reply action for an item, or when the Reply method is called for the item, which is an instance of the parent object. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers


    Thursday, November 2, 2017 9:08 PM
  • Latest versions of Outlook 2016 (after Sprint 2016?) expose Explorer.ActiveInlineResponseWordEditor property (returns Word's Document object). You can use that to modify the body with greater granularity instead of resetting the whole thing by setting the MailItem.HTMLBody property.

    If you need to support older versions of Outlook, you can use Redemption and its SafeExplorer.ReadingPane.WordEditor property to access the Word.Document object of the inline response.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, November 3, 2017 12:17 AM
  • Hi gsustalo,
    I tried to modify the HTMLBody in InlineRespnse using below code.
    private void Explorer_InlineResponse(object Item)
            {
                if (Item is Outlook.MailItem) {
                    mailItem = (Outlook.MailItem)Item;
                    mailItem.HTMLBody = mailItem.HTMLBody.Replace("Test", "TEST");
                }
            }
    It worked for me to replace the text from HTML Body and did not make unpleasant flickering.
    Could you tell us how did you modify the HTMLBody? What's the version of your OutLook?
    Best Regards,
    Terry

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 3, 2017 3:05 AM
  • Hello Eugene Astafiev,

    Yes, mail item instance comes from InlineResponse event handler parameters.

    I don't know how can be usefull Explorer.SelectionChange, Addin musts change text when it is shown on the Message Pane on edition


    • Edited by gsustalo Friday, November 3, 2017 8:04 AM
    Friday, November 3, 2017 7:56 AM
  • Hello Terry X,

    It is the way that I'm implementing my code and the way that makes the problem.

    I'm using OutLook 2016.

    Thank you


    • Edited by gsustalo Friday, November 3, 2017 8:04 AM
    Friday, November 3, 2017 8:00 AM
  • Hi gsustalo,

    Did you install any add-ins which may cause this issue? You could try to disable other add-ins and do the test again.

    Could you tell us the build number of your Office and the version of your operation system so we could try to reproduce your issue?

    By the way, I have also done the test using Explorer.SelectionChange. However, I still failed to reproduce your issue.

    Here is the code I'm using. Did you ever do the test?

    private void Explorer_SelectionChange()
            {
                Outlook.Selection selection = Globals.ThisAddIn.Application.ActiveExplorer().Selection;
                if (selection.Count > 0) {
                if (selection[1] is Outlook.MailItem)
                {
                    mailItem = (Outlook.MailItem)selection[1];
                    mailItem.HTMLBody = mailItem.HTMLBody.Replace("TEST", "YYYYY");
                }
                }
            }

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 3, 2017 8:18 AM
  • Hi Terry,

    This is my code (body musts be modified only on compose mode):

            private void Explorer_SelectionChange()
            {
                Outlook.Selection selection = Globals.ThisAddIn.Application.ActiveExplorer().Selection;
                if (selection.Count > 0)
                {
                    if (selection[1] is Outlook.MailItem)
                    {
                        _mailItem = (Outlook.MailItem)selection[1];
                        if (!_mailItem.Sent)
                            _mailItem.HTMLBody = "TEST";
                    }
                }
            }
    

    The problem is that:

    - Firstly, original body is shown for tenths of a second

    - Nextly, text is replaced causing a weird effect

    Thank you, Jesús

    Friday, November 3, 2017 9:03 AM
  • Hi Jesus,

    I still failed to reproduce your issue.

    Would you still get the issue if you modify the Body instead of HTMLBody?

    If you change the mail’s HTML Body via a button click instead of the InlineResponse event or SelectionChange event, would you get the issue?

    Besides, I would suggest you repair your Office and then test again.

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, November 3, 2017 9:45 AM
  • Hi gsustalo,

    I need confirm with you what do you mean the "Flickering Effect". 

    I have record a gif. In first part of the gif, I select mails without running the add-ins, in the second part of the gif, I enabled the add-in and do the test again. Where do you think it is the Flickering Effect? Could you try to record a gif to show us your testing result?

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, November 16, 2017 9:34 AM
  • I am also facing the same issue with InlineResponse. When the MailItem has external image URL, clicking on inline Reply/Forward is causing mailItem.HtmlBody="MY BODY SAMPLE" to flicker or freeze the Outlook 2016 instance for some time.

    Kunal Chowdhury [Microsoft MVP - Windows Development]
    Windows 10 Champion, Active Blogger @ http://www.kunal-chowdhury.com
    Git Tutorial - http://git.kunal-chowdhury.com

    Friday, February 23, 2018 12:43 PM