Re: Do all OOM objects support the IMessage interface?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



No, there is no base object, and there is a reason against it: what if you
need to add a property/method to the base class? You can't do that since all
the COM interfaces (unlike classes) are engraved in stone for eternity. So
all Outlook objects are derived from IDispatch instead of using some
intermediary base interface.
You can of course use late binding, but it is a real PITA in C++...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Dave Smith" <Dave@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:ujpDKENqFHA.3108@xxxxxxxxxxxxxxxxxxxxxxx
> Dmitry,
>
> I am sorry for the confusion. My question has nothing to do with a
> stickynote. I don't care about stickynotes, except as they might gum the
> works of a generic interface to Outlook items.
>
> I am a C++ programmer. Polymorphism in ingrained in my bones. If I have a
> collection of similar objects, especially if these similar objects are
> specializations of some base functionality, I look for a base class
> through which I can collect and deal with these objects generically.
>
> So far, the closest I have come to this with the OOM objects is the common
> IDispatch interface. This is a very unwieldy interface.
>
> Do MailItem, TaskItem, TaskRequestItem, etc. have a common base class
> object, like a generic OutlookItem? From what I hear so far, the answer to
> this is "No."
>
> So I am writing 39 lines of code to do something that I could do in 15 or
> less lines of code, if I could use the Outlook objects directly. But you
> tell be that I cannot assume the type of Outlook item that is currently
> being handled in the OnSubmit routine. So I am querying and setting the
> common properties and calling the common methods of the Outlook items via
> their common IDispatch interface.
>
> So, my original question in this thread was, "What will it hurt if I call
> *ONLY* the properties and methods common to all objects through a MailItem
> object wrapper, even though the real item may be a TaskRequestItem?"
>
> I am very grateful for you time and support, Dmitry. So far you have been
> infinitely more helpful than the official Microsoft support for which I am
> paying.
>
> Dave Smith
>
> "Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
> news:uHWTb1MqFHA.2816@xxxxxxxxxxxxxxxxxxxxxxx
>> Why would adding a new sticky nore fire the OnSubmit callback? It is
>> never submitted, only created and saved, pretty much like a regular
>> message is saved to the Drafts folder.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Dave Smith" <Dave@xxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:uc%23818KqFHA.2696@xxxxxxxxxxxxxxxxxxxxxxx
>>> OK, now I have another question. It appears that adding a new NoteItem
>>> does not fire the OnSubmit event in my Exchange Client Extension.
>>> Therefore, all items being processed by my OnSubmit routine will
>>> implement the IMessage interface. (It would be nice if OOM provided a
>>> "base" object to represent the common functionality of all
>>> IMessage-based objects - does it?) Given that all items being processed
>>> share this common base of functions, what is really wrong with my
>>> pretending that every item is a MailItem - as long as I only call
>>> properties and methods (like EntryID, Copy, and Save) that are common to
>>> all of these objects.
>>>
>>> I will say that this code has been running for some time (measured in
>>> months if not years) while making this assumption. It was not until I
>>> recently heard of the problem using MailItem.Save if the OOM item was
>>> actually a TaskRequest item that I began to question this, which problem
>>> still exists if I use TaskRequestItem.Save. That problem with
>>> TaskRequestItem.Save is currently being researched by Microsoft support.
>>>
>>> Dave Smith
>>>
>>> "Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
>>> news:uy2Vhh1pFHA.3180@xxxxxxxxxxxxxxxxxxxxxxx
>>>> If it is being sent, then yes, it is a message which must support the
>>>> IMessage interface. On thee Extended MAPI level all items are IMessage
>>>> objects; thee only difference is the set off properties, most important
>>>> being the message class.
>>>> Most objects in OOM that sit on top of an IMessage return IMessage
>>>> through the MAPIOBJECT property. The only exception is NoteItem (sticky
>>>> note). But it is never sent.
>>>>
>>>> Dmitry Streblechenko (MVP)
>>>> http://www.dimastr.com/
>>>> OutlookSpy - Outlook, CDO
>>>> and MAPI Developer Tool
>>>>
>>>> "Dave Smith" <Dave@xxxxxxxxxxxxxxxxxxxx> wrote in message
>>>> news:%23EzA4y0pFHA.3104@xxxxxxxxxxxxxxxxxxxxxxx
>>>>>I have been cautioned in this forum against assuming that items being
>>>>>processed by OnSubmit in my Exchange Client Extension are of a
>>>>>particular type of OOM object. That is, I was wrapping all items
>>>>>incoming to OnSubmit in a Outlook MailItem object, even thoug the item
>>>>>might actually be a TaskRequest item. So, I no longer do that.
>>>>>
>>>>> However, can I at least assume that any item coming into OnSubmit will
>>>>> suport the MAPI IMessage interface?
>>>>>
>>>>> Dave Smith
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: Do all OOM objects support the IMessage interface?
    ... works of a generic interface to Outlook items. ... the closest I have come to this with the OOM objects is the common ... if I could use the Outlook objects directly. ... > Why would adding a new sticky nore fire the OnSubmit callback? ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Do all OOM objects support the IMessage interface?
    ... > OutlookSpy - Outlook, CDO ... >> works of a generic interface to Outlook items. ... >> specializations of some base functionality, I look for a base class ... >> their common IDispatch interface. ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Unification of Methods and Functions
    ... I am suggesting that we write factory methods using classmethod to give ... my classes all implement an interface which I'll call 'shape ... Rectangle and Ellipse have a common base class, ...
    (comp.lang.python)
  • Re: Forms inheritance best practice
    ... That really depends on the nature of your base class. ... > common class or implement a common interface. ... > derived form will of course be instantiated by the derived form. ...
    (microsoft.public.dotnet.framework)
  • Re: Interfaces Question - I am missing something
    ... With an interface, _any_ class can implement the interface, and code that relies on the interface will "just work". ... Again, the actual implementation can be done long after the code that uses the implementation was written, because it complies with the contract defined in the base class that the using code _does_ know about. ... In Java, all methods are virtual by default, making this sort of thing that much more common and important ). ... since you're asking the question I assume that you're relatively new to OOP. ...
    (comp.lang.java.programmer)