none
Can I resolve a Reminder to it's Appointment or Task using the Outlook Object Model? RRS feed

  • Question

  • using Microsoft.Office.Interop.Outlook;

    Application ol = new Application();

    foreach (Reminder r in ol.Reminders)

    {

    // how can I resolve each Reminder to it's associated Appointment or Task ?

    }


    Sunday, July 14, 2013 7:17 AM

Answers

  • Through trial and error, I've found that the COMException does not get thrown by the .Item accessor when a second copy of Outlook is loaded manually and open on the desktop, before executing this code.

    I'm not clear why this changes the behavior, but unfortunately this doesn't help me as I need to automate an unattended Outlook app in the background.

    Tuesday, July 16, 2013 10:24 AM
  • Outlook doesn't support using the running unattended from a service or scheduler or Web service, or anything like that. Is that what you're trying to do?

    Ken Slovak MVP - Outlook

    Tuesday, July 16, 2013 2:24 PM
    Moderator
  • That's correct, Outlook code is unsupported and won't work correctly when run from a Windows service.

    You could use Redemption (www.dimastr.com/redemption/rdo) for that. Redemption is a COM wrapper for MAPI, and can be run from within a Windows service. It's a somewhat different object model based on MAPI and CDO type objects and classes, but it can be used for what you want.


    Ken Slovak MVP - Outlook

    Tuesday, July 16, 2013 3:11 PM
    Moderator

All replies

  • Use Reminder.Parent, but check Parent.MessageClass first so that you can cast it to the appropriate item type (it could be any of the standard item types except NoteItem).

    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Monday, July 15, 2013 2:17 PM
    Moderator
  • Thanks for your assistance, but it seems all the parents in my foreach loop are of type RemindersClass. 

    using Microsoft.Office.Interop.Outlook;

    Application ol = new Application();

    foreach (Reminder r in ol.Reminders)

    {

        dynamic p = r.Parent;  // p is always a RemindersClass

        dynamic item = p.MessageClass;   //  throws  RuntimeBinder exception RemindersClass has no MessageClass

    }

    Have I misunderstood your suggestion?

    Monday, July 15, 2013 7:49 PM
  • I must be wrong! I'll look into it further when I get a chance tonight or tomorrow.

    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Monday, July 15, 2013 8:24 PM
    Moderator
  • Try r.Item rather than .Parent

    Ken Slovak MVP - Outlook

    Monday, July 15, 2013 8:59 PM
    Moderator
  • Hi Ken,

    Thanks for your suggestion, but accessing r.Item throws a COMException  0x80010105 "Server Error"

    Tuesday, July 16, 2013 3:24 AM
  • Through trial and error, I've found that the COMException does not get thrown by the .Item accessor when a second copy of Outlook is loaded manually and open on the desktop, before executing this code.

    I'm not clear why this changes the behavior, but unfortunately this doesn't help me as I need to automate an unattended Outlook app in the background.

    Tuesday, July 16, 2013 10:24 AM
  • Outlook doesn't support using the running unattended from a service or scheduler or Web service, or anything like that. Is that what you're trying to do?

    Ken Slovak MVP - Outlook

    Tuesday, July 16, 2013 2:24 PM
    Moderator
  • I'm trying write a windows service that uses Outlook Reminders to send messages to my Media Center so that, for example, I get a dialog on the TV warning me that it's someone's birthday or anniversary 'soon'.  This might sound like an elementary programming exercise, but believe me if you forget your Anniversary it's non-trivial.

    I can set a timer event for each reminder, and when it fires I can generate a Media Center prompt on the TV.  This is currently working.  However, I was hoping to resolve each reminder to its Appointment so that I can include the due date in the onscreen prompt.

    From your reply, I can see I'm trying to do something that is not supported.  As you can probably tell, I've not used Outlook Automation before.  Thanks for your time.

    Tuesday, July 16, 2013 2:50 PM
  • That's correct, Outlook code is unsupported and won't work correctly when run from a Windows service.

    You could use Redemption (www.dimastr.com/redemption/rdo) for that. Redemption is a COM wrapper for MAPI, and can be run from within a Windows service. It's a somewhat different object model based on MAPI and CDO type objects and classes, but it can be used for what you want.


    Ken Slovak MVP - Outlook

    Tuesday, July 16, 2013 3:11 PM
    Moderator