none
Accessing mailitem user property corrupts Outlooks UI Undo feature RRS feed

  • Question

  • Hello,

    Here is my situation: When the user does a drag-n-drop or move an email to another folder, I am trying to read a user property of the email. If I try to access this user property in the Folder_BeforeItemMove event, then the Undo using the Outlook UI does not work.

    I am using the following code:

    Dim strProperty As String
    
    Dim strPropertyName as String = "myproperty"
    ...
    
    strProperty = Item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/" & strPropertyName)
    
    ...
    
    
    End Sub

    If I comment-out the get property line, the Undo features works fine. 

    Any suggestions as to why this might be happening or Is there any other way that I can use to by-pass the Undo feature from being corrupted?

    Thanks.
    Anand

    Thursday, May 10, 2012 11:39 PM

Answers

  • It seems to have solved my issue. Here is what we did ...

    The m_mailItem object was not released as this was still pointing to the item that was moved. On m_Fldobj_BeforeItemMove event, I had to set it to nothing and do garbage collection inorder to release it and then the Undo from Outlook UI worked.

    Thanks.
    Anand


    Anand Kumar

    • Marked as answer by a3kumarz Tuesday, May 15, 2012 2:06 AM
    Tuesday, May 15, 2012 2:06 AM

All replies

  • please check if the same happens if you access user property using Item.UserProperties.Find

    Friday, May 11, 2012 6:52 AM
  • Also, check to make sure that you are releasing all references to the item before an undo is attempted.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    Reminder Manager, Extended Reminders, Attachment Options
    http://www.slovaktech.com/products.htm
     
     
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:d8a12b9a-244c-4b76-9a37-5ad6a564d2a1...

    please check if the same happens if you access user property using Item.UserProperties.Find


    Ken Slovak MVP - Outlook
    Friday, May 11, 2012 2:05 PM
    Moderator
  • I tried using the Item.UserProperties.Find but with no luck. I will look at Ken Slovak's suggestion and see if it helps.

    Thanks.


    Anand Kumar

    Saturday, May 12, 2012 12:36 AM
  • I believe Ken Slovak is correct, it has something to do with the reference to the mailitem object. I check out the code and here is my situation:

    Within the same explorer wrap class, I have the following objects declared with withevents
    Private withevents m_Fldobj as Outlook.Folder
    Private withevents m_mailItem as Outlook.Mailitem
    In m_objExpl.selectionchange event, the m_mailItem object is assigned: 
    m_mailItem = m_objExpl.selection(1)
    In m_objExpl.FolderSwitch and in m_objExpl.Activate events, the m_Fldobj object is assigned:
    m_Fldobj = m_objExpl.currentfolder
    For the m_Fldobj object, i am trapping the m_Fldobj_BeforeItemMove event and for the m_mailItem, i am trapping the m_mailItem_Foward event to run some code.

    I found out that if I comment-out the code inside the m_objExpl.FolderSwitch and the m_objExpl.Activate events, the Undo using Outlook's UI still does not work but if I comment-out the whole events (including the headers), the Undo feature works fine but now I will not be able to run my code as there is no trap on those events.

    Any suggestions?

    Thanks
    Anand

    Anand Kumar

    Monday, May 14, 2012 10:20 AM
  • It seems to have solved my issue. Here is what we did ...

    The m_mailItem object was not released as this was still pointing to the item that was moved. On m_Fldobj_BeforeItemMove event, I had to set it to nothing and do garbage collection inorder to release it and then the Undo from Outlook UI worked.

    Thanks.
    Anand


    Anand Kumar

    • Marked as answer by a3kumarz Tuesday, May 15, 2012 2:06 AM
    Tuesday, May 15, 2012 2:06 AM