none
Change MessageClass of a MailItem RRS feed

  • Question

  • Is there a way to change the MessageClass of an item without firing the Write event of the form it's currently set to?

    I'm trying to change the MessageClass from IPM.Note.EnterpriseVault.PendingArchive to IPM.Note but the form for IPM.Note.EnterpriseVault.PendingArchive has a Write event that always returns False which is causing my change to be aborted.

    I'm a systems administrator so if this can be done with VBscript or Powershell that would be great but I've also got a C# program with the same problem. At this point I'll take whatever solution I can get.

    Thanks.


    Chris Summers
    Wednesday, December 28, 2011 1:33 PM

Answers

  • If will need to use an API other than Outlook Object Model to do that.

    Extended MAPI (C++ or Delphi only), CDO 1.21 (not supported in .Net and is not installed by Outlook 2010) or Redemption (which wraps Extended MAPi and is accessible from any language, including .Net languages).

    In Redemption, you can something like the following

      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set Msg = Session.GetMessageFromID(YourOutlookMailItem)
      Msg.MessageClass = "IPM.Note"
      Msg.Save

     


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by Chris Summers Tuesday, January 3, 2012 6:36 PM
    Saturday, December 31, 2011 8:57 PM

All replies

  • Hi Chris,

    Thanks for your post.

    As far as I know, there is no such thing you can disable a event unless you un-register this event handler. In addition, why don't add some logical statement for the Write event to determine on which situation return false or true.

    I look forward to hearing of you.


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 30, 2011 7:16 AM
    Moderator
  • If will need to use an API other than Outlook Object Model to do that.

    Extended MAPI (C++ or Delphi only), CDO 1.21 (not supported in .Net and is not installed by Outlook 2010) or Redemption (which wraps Extended MAPi and is accessible from any language, including .Net languages).

    In Redemption, you can something like the following

      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set Msg = Session.GetMessageFromID(YourOutlookMailItem)
      Msg.MessageClass = "IPM.Note"
      Msg.Save

     


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by Chris Summers Tuesday, January 3, 2012 6:36 PM
    Saturday, December 31, 2011 8:57 PM
  • Thank you. 
    Chris Summers
    Tuesday, January 3, 2012 6:37 PM
  • Hi, i am new to outlook Addin 2007 development. I am using Custom forms for Appointments in Outlook. Inside my program i am changing the Message class from an existing default form "IPM.Appointment" to my own custom form "IPM.Appointment.MyCustomForm". 

    Now the problem that i am Facing is that the newly applied custom form is not showing for that particular appointment, even though the message class is updated. But when i reload the Outlook application, the new custom forms are displaying for the appointment item.

    can anyone please help me on this?

    Friday, August 2, 2013 7:02 AM
  • This happens because either Outlook or your code holds a reference to that appointment.

    If you are using .Net, make sure you release the appointment using Marshal.ReleaseComObject.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, August 8, 2013 8:13 PM