none
Why custom properties are lost in the forward ? RRS feed

  • Question

  • Hi,

    I solved one problem and another comes - in the past (3 weeks ago) when I had some custom properties in the mail item and forwarded it, they persisted. It worked perfectly, 100%. Now it doesn't. They are completelly removed. I tried to disable all my add-ins, to be sure it has nothing with my code and still it is so. 

    Should it work or not (should they stay with the message or not)?

    Thanks

    F.

    Tuesday, April 17, 2012 3:12 PM

Answers

  • Are the properties UserProperties or MAPI named properties or what? How are you adding them, and what version of Outlook is this?
     
    In general a UserProperty should remain with a forwarded item, but named properties won't.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Filip Mateasko" <=?utf-8?B?RmlsaXAgTWF0ZWFza28=?=> wrote in message news:4f7639a8-0fde-4006-acd4-46e7b547bba2...

    Hi,

    I solved one problem and another comes - in the past (3 weeks ago) when I had some custom properties in the mail item and forwarded it, they persisted. It worked perfectly, 100%. Now it doesn't. They are completelly removed. I tried to disable all my add-ins, to be sure it has nothing with my code and still it is so. 

    Should it work or not (should they stay with the message or not)?

    Thanks

    F.


    Ken Slovak MVP - Outlook
    Tuesday, April 17, 2012 3:22 PM
    Moderator

All replies

  • Are the properties UserProperties or MAPI named properties or what? How are you adding them, and what version of Outlook is this?
     
    In general a UserProperty should remain with a forwarded item, but named properties won't.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Filip Mateasko" <=?utf-8?B?RmlsaXAgTWF0ZWFza28=?=> wrote in message news:4f7639a8-0fde-4006-acd4-46e7b547bba2...

    Hi,

    I solved one problem and another comes - in the past (3 weeks ago) when I had some custom properties in the mail item and forwarded it, they persisted. It worked perfectly, 100%. Now it doesn't. They are completelly removed. I tried to disable all my add-ins, to be sure it has nothing with my code and still it is so. 

    Should it work or not (should they stay with the message or not)?

    Thanks

    F.


    Ken Slovak MVP - Outlook
    Tuesday, April 17, 2012 3:22 PM
    Moderator
  • publicvoid SetUserProperty(string propertyName, OL.OlUserPropertyType propertyType, object value)        {            try            {                object outVal;                     string fullName = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/" + propertyName;                    PropertyAccessor.SetProperty(fullName, value);                    Marshal.ReleaseComObject(PropertyAccessor);            }            catch (System.Exception)            {         

    throw;            }        }

           But I think this is the same as it was...

    F.

     
    Tuesday, April 17, 2012 3:24 PM
  • Outlook 2010 Win7
    Tuesday, April 17, 2012 3:25 PM
  • That's a MAPI named property in the PS_PUBLIC_STRINGS namespace, the same one used for UserProperties. However, the way the property is being added isn't creating a UserProperty.
     
    You can set/read a UserProperty the way you're showing, but if it's created that way it won't be a UserProperty and won't be added to the UserProperties collection.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Filip Mateasko" <=?utf-8?B?RmlsaXAgTWF0ZWFza28=?=> wrote in message news:9c2dcb0c-769b-4ecb-8879-a2526540d7ea...

    publicvoid SetUserProperty(string propertyName, OL.OlUserPropertyType propertyType, object value)        {            try            {                object outVal;                     string fullName = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/" + propertyName;                    PropertyAccessor.SetProperty(fullName, value);                    Marshal.ReleaseComObject(PropertyAccessor);            }            catch (System.Exception)            {         

    throw;            }        }

           But I think this is the same as it was...

    F.

     

    Ken Slovak MVP - Outlook
    Tuesday, April 17, 2012 3:28 PM
    Moderator
  • Ok, finally I've found it - it was in this method, so thanks for direction - 

    The method was originally:

    public void SetUserProperty(string propertyName, OL.OlUserPropertyType propertyType, object value)
           {
               try
               {
                   object outVal;
                   if (!HasUserProperty(propertyName, out outVal))
                   {
                       UserProperties.Add(propertyName, propertyType);
                       UserProperties[propertyName].Value = value;
                   }
                   else
                   {
                       string fullName = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/" + propertyName;
                       PropertyAccessor.SetProperty(fullName, value);
                   }
                       Marshal.ReleaseComObject(PropertyAccessor);
     
               }
               catch (System.Exception)
               {
                   throw;
               }
           }

    but when I was looking for previous problem, I commented out the part with user properties for some reason. however, thanks again for the direction !

    Filip 

    Tuesday, April 17, 2012 3:36 PM