How to trigger presence change for a contact in IM client application?

Manoj 86 Reputation points
2022-03-22T12:04:36.737+00:00

I am making an IM client application for integrating presence in Outlook by following this article - https://learn.microsoft.com/en-us/office/client-developer/shared/integrating-im-applications-with-office#introduction

When Outlook starts, it calls the method BatchGetContactInformation present in the IContact interface to get the presence for a contact and it is working fine for me. But for regularly monitoring a contact's presence, Outlook creates subscriptions for those contacts using the Subscribe method in the IContactSubscription interface. In the docs, it is written

The IContactSubscription.Subscribe method allows an IM client application to access presence observers for the contact. It can use a polling strategy to get the presence from the server for the contacts for that the IM client application has subscribed to.

So, I am using a timer which runs at an interval of 5 seconds and calls the RaiseOnContactInformationChangedEvent function for every contact in the list of subscribed contacts. Here is the implementation of the event:

public event _IContactEvents_OnContactInformationChangedEventHandler OnContactInformationChanged;  
public void RaiseOnContactInformationChangedEvent(ContactInformationChangedEventData _eventData)  
{  
    if(OnContactInformationChanged != null)  
    {  
        OnContactInformationChanged(this, _eventData);  
    }  
}  

I have implemented the ContactInformationChangedEventData interface and made a class which is ComVisible. I have added ContactInformationType.ucPresenceAvailabilityin the ContactInformationType[] of the eventData but Outlook is not calling the GetContactInformation or BatchGetContactInformation method for that contact. How can I make Outlook call those functions for a contact?

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,249 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,489 questions
{count} votes