Python - Office Communicator API - Is it possible to send messages despite restrictions

4.4k Views Asked by At

I've messed around with a number of Office programs using win32com in Python.

Excel has been useful and Outlook was simple to satisfy my basic use needs.

I have Microsoft Lync and I'm having trouble using it.

I know there are restrictions but what I would like to do is; send a message, detect received messages and reply.

I have used the below code to open a new window:

import win32com.client

msg = win32com.client.Dispatch('Communicator.UIAutomation')
msg.InstantMessage('[email protected]')

This works fine to open a messenger window but any methods to send a message generally raise a "Not implemented" error. I know the api is restricted but I was wondering whether it is even possible to send message this way or detect received messages, or is there another way of communicating with Communicator?

I don't really want to use a SendKeys method to write a message. Any help will be appreciated.

1

There are 1 best solutions below

0
On

Instead of trying to drive the Communicator GUI program, you might want to consider implementing an interface to the underlying chat protocol.

Communicator can speak the XMPP protocol - the same as Google Talk, Facebook Chat, etc.

From Wikipedia:

Furthermore, several enterprise IM software products that do not natively use XMPP nevertheless include gateways to XMPP, including:

  • IBM Lotus Sametime
  • Microsoft Lync Server (formerly named Microsoft Office Communications Server – OCS)

You should be able to implement your own XMPP client. libpurple, the chat protocol library behind Pidgin, implements XMPP; you could use this if you wanted to.