Problem with Microsoft Interop Outlook

ajinkya patil 1 Reputation point
2022-04-09T04:58:00.617+00:00

Hello all,
I am trying to collect the body of a mail item under composition using mail.Body collection API, and on every key press this API is getting triggered. If this mail item has a scroll bar due to huge content on every body collection call the scroll bar jumps up and down. To give the gist of what is happening please see the code below which is in C#.

        var outApp = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;  
        var session = new Redemption.RDOSession();  
        session.MAPIOBJECT = outApp.Session.MAPIOBJECT;  
        while (true)  
        {  
            var item = outApp.ActiveInspector().CurrentItem as Outlook.MailItem;  
            Console.WriteLine(item.Body);  
        }  

In actual code the API is triggered only once per key press but in continuous typing this can be considered to be running in an infinite loop.

Please find the attached image GIF of the UI glitch while the program is running.

I would really appreciate suggestions or workarounds if any, thanks a lot.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,480 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,885 questions
Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,000 questions
0 comments No comments
{count} votes