none
Can I user user-define message in outlook addin? RRS feed

  • Question

  • HI,all,

    I wrote an addin, and I want it communicate with another exe, so can I user user-defined message there?

    I mean, I want exe post message to my addin.

    Thanks.

    Monday, March 4, 2013 7:35 AM

Answers

  • post a user defined window message? I think you can, but why not use simpler communication mechanisms like pipes, etc?
    Monday, March 4, 2013 8:30 AM
  • As long as a COM addin is part of the Outlook.Application.COMAddIns collection and you set up the addin to be exposed to COM it should work. There are different ways to expose the addin to COM depending on whether the addin is a VSTO addin or a shared addin of course.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:37078b2c-b355-41f7-a0a2-33480af35c36...
    Ken's advice is as always excellent - just remember that for his proposition to work you will have to register your COM objects in registry which would be kind of hard with ClickOnce deployment. Also take into account appartment model and marshalling.

    Ken Slovak MVP - Outlook
    Tuesday, March 5, 2013 3:38 PM
    Moderator
  • Ken's idea works like any other out of process COM server interaction - your add-in exposes COM interface which your external app can Query for and interact with invoking methods. For bidirectional communication using this method you will have to pass your own COM exposed interface back to add-in as one of parameters of aforementioned methods (and make sure that your COM marshaller knows how to marshal it) so it can get a little tricky.

    Thursday, March 7, 2013 10:46 AM
  • If bidirectional communication is desired a function can be used as long as you don't mind waiting for a synchronous response from one or the other program. Otherwise you'd need to call a method that returned immediately after starting something, then the other code would set a property or call a method in the original calling program to return a result or to notify it that processing was finished.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:4ae6120b-3e12-4459-881b-8fff4abaf768...

    Thank you very much.

    I think using pipe is a proper way here. I am trying and will let know the result if I did.

    Thank you always.


    Ken Slovak MVP - Outlook
    Thursday, March 7, 2013 6:54 PM
    Moderator

All replies

  • post a user defined window message? I think you can, but why not use simpler communication mechanisms like pipes, etc?
    Monday, March 4, 2013 8:30 AM
  • pipes,ok,let me try.

    because addin is not a simple win32 exe application,so I don't know how to put the code of pipes, user-define messages and so on.

    for example, the entry for outlook's addin is the function OnConnection.

    Monday, March 4, 2013 10:10 AM
  • no, it has nothing with OnConnection.

    For pipes i will let you to discover it on your own, there is plenty of documentation

    As for window messages - it will work as long as you either have currently modal window displayed (which of course has 'top' message loop so you will actually see this message) or if you install message loop hook that will allow you to see messages processed by Outlook message pump.

    Monday, March 4, 2013 10:41 AM
  • Another possibility would be to expose a method or property from the addin code publicly so the external exe can directly communicate with the addin. That's what I would do.
     
    There's a lot of documentation on how to do that, depending on the platform and language used and whether VSTO or a shared addin is being used, such as http://msdn.microsoft.com/en-us/library/vstudio/bb608621(v=vs..100).aspx

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:0d05f40f-4eb5-44b7-a67a-1acfd719a71a...

    no, it has nothing with OnConnection.

    For pipes i will let you to discover it on your own, there is plenty of documentation

    As for window messages - it will work as long as you either have currently modal window displayed (which of course has 'top' message loop so you will actually see this message) or if you install message loop hook that will allow you to see messages processed by Outlook message pump.


    Ken Slovak MVP - Outlook
    Monday, March 4, 2013 6:15 PM
    Moderator
  • thanks.I know about pipe but only use it in exe program. I will try and see if it works.
    Tuesday, March 5, 2013 9:22 AM
  • Thanks first.

    Actuallly it is not a external exe,  it is child exe which is called by the addin.

    I am thinking at pipe and your way which is more proper here.

    Tuesday, March 5, 2013 9:25 AM
  • Ken's advice is as always excellent - just remember that for his proposition to work you will have to register your COM objects in registry which would be kind of hard with ClickOnce deployment. Also take into account appartment model and marshalling.
    Tuesday, March 5, 2013 10:19 AM
  • As long as a COM addin is part of the Outlook.Application.COMAddIns collection and you set up the addin to be exposed to COM it should work. There are different ways to expose the addin to COM depending on whether the addin is a VSTO addin or a shared addin of course.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:37078b2c-b355-41f7-a0a2-33480af35c36...
    Ken's advice is as always excellent - just remember that for his proposition to work you will have to register your COM objects in registry which would be kind of hard with ClickOnce deployment. Also take into account appartment model and marshalling.

    Ken Slovak MVP - Outlook
    Tuesday, March 5, 2013 3:38 PM
    Moderator
  • Thanks first.

    I want to communicate between dll and exe because in the dll, exe is called, and I want exe to inform dll when it finish its work.

    You suggest that I can expose a function that exe can use, and then?

    Thursday, March 7, 2013 8:07 AM
  • which proposal are you considering? Ken's COM interface?
    Thursday, March 7, 2013 9:48 AM
  • I have not decided yet, I know your idear, but do not quite understand how ken's solution works.

    So, I am figuring it out.

    Thanks for you two.

    Thursday, March 7, 2013 10:13 AM
  • Ken's idea works like any other out of process COM server interaction - your add-in exposes COM interface which your external app can Query for and interact with invoking methods. For bidirectional communication using this method you will have to pass your own COM exposed interface back to add-in as one of parameters of aforementioned methods (and make sure that your COM marshaller knows how to marshal it) so it can get a little tricky.

    Thursday, March 7, 2013 10:46 AM
  • Thank you very much.

    I think using pipe is a proper way here. I am trying and will let know the result if I did.

    Thank you always.

    Thursday, March 7, 2013 11:42 AM
  • If bidirectional communication is desired a function can be used as long as you don't mind waiting for a synchronous response from one or the other program. Otherwise you'd need to call a method that returned immediately after starting something, then the other code would set a property or call a method in the original calling program to return a result or to notify it that processing was finished.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:4ae6120b-3e12-4459-881b-8fff4abaf768...

    Thank you very much.

    I think using pipe is a proper way here. I am trying and will let know the result if I did.

    Thank you always.


    Ken Slovak MVP - Outlook
    Thursday, March 7, 2013 6:54 PM
    Moderator