none
Using PropertyAccessor to Set and Get properties in a meeting request

    Question

  • Hi,

    I am using outlook 2007 and I am trying to set and get properties through PropertyAccessor.SetProperty and PropertyAccessor.GetProperty.

    This works for a normal appointment item when created for self. But when attendees are added to the appointment item then the properties are not copied to the attendees appointment (not only in the appointment invitation mail but in the appointment itself), though the properties are added to the self.  I checked it through OutlookSpy.

    Here is the code that I use for set and get properties. Should I use a different GUID than this "00020329-0000-0000-C000-000000000046" ?

     public static bool CreateExtendedProperty(object outlookItem, object value)
            {
                try
                {
                    
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        (outlookItem as Outlook.AppointmentItem).PropertyAccessor.SetProperty(prop, value);
                    }
                 return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in adding assignment data to the outlook item. " + ex.Message);
                    return false;
                }


            }



    public static object GetExtendedPropertyValue(object outlookItem, string property)
            {
                try
                {
                   
                    object result = null;
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        result = (outlookItem as Outlook.AppointmentItem).PropertyAccessor.GetProperty(prop);
                    }
                    

                    return result;
                }
                catch (Exception ex)
                {
                    return null;
                }
            }

    -Geetha
    Wednesday, February 2, 2011 10:01 AM

Answers

  • The GUID is fine, that's PS_PUBLIC_STRINGS, and is what is normally used.
     
    I don't think you're going to be able to do what you want. You certainly can get the appointment item from the meeting using GetAssociatedAppointment() and then add your named properties to the appointment. However when sending items the properties are going to be stripped out.
     
    I don't know if this could be a workaround for you, but if the senders and recipients will all be using your addin you can set the named properties to be x-headers when the items are sent out and the addin on the receiving end could look for those x-headers in the Internet headers property and parse them out and add them to the received meeting invitations.
     
    All the Internet headers are stored in the received item as one long string. The property is PR_TRANSPORT_MESSAGE_HEADERS ("http://schemas.microsoft.com/mapi/proptag/0x007D001E") for ANSI (PT_STRING8) , or for Unicode it would be PR_TRANSPORT_MESSAGE_HEADERS_W ("http://schemas.microsoft.com/mapi/proptag/0x007D001F").
     
    The MAPI property tag you'd use to create the x-header would be : "http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/BookingType"
     
    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "gr_gr" <=?utf-8?B?Z3JfZ3I=?=> wrote in message news:08ecce0a-be0a-4d42-9bbd-7d1691b8abde...
    Hi,

    I am using outlook 2007 and I am trying to set and get properties through PropertyAccessor.SetProperty and PropertyAccessor.GetProperty.

    This works for a normal appointment item when created for self. But when attendees are added to the appointment item then the properties are not copied to the attendees appointment (not only in the appointment invitation mail but in the appointment itself), though the properties are added to the self.  I checked it through OutlookSpy.

    Here is the code that I use for set and get properties. Should I use a different GUID than this "00020329-0000-0000-C000-000000000046" ?

     public static bool CreateExtendedProperty(object outlookItem, object value)
            {
                try
                {
                    
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        (outlookItem as Outlook.AppointmentItem).PropertyAccessor.SetProperty(prop, value);
                    }
                 return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in adding assignment data to the outlook item. " + ex.Message);
                    return false;
                }


            }



    public static object GetExtendedPropertyValue(object outlookItem, string property)
            {
                try
                {
                   
                    object result = null;
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        result = (outlookItem as Outlook.AppointmentItem).PropertyAccessor.GetProperty(prop);
                    }
                    

                    return result;
                }
                catch (Exception ex)
                {
                    return null;
                }
            }

    -Geetha

    Ken Slovak MVP - Outlook
    Wednesday, February 2, 2011 3:18 PM

All replies

  • The GUID is fine, that's PS_PUBLIC_STRINGS, and is what is normally used.
     
    I don't think you're going to be able to do what you want. You certainly can get the appointment item from the meeting using GetAssociatedAppointment() and then add your named properties to the appointment. However when sending items the properties are going to be stripped out.
     
    I don't know if this could be a workaround for you, but if the senders and recipients will all be using your addin you can set the named properties to be x-headers when the items are sent out and the addin on the receiving end could look for those x-headers in the Internet headers property and parse them out and add them to the received meeting invitations.
     
    All the Internet headers are stored in the received item as one long string. The property is PR_TRANSPORT_MESSAGE_HEADERS ("http://schemas.microsoft.com/mapi/proptag/0x007D001E") for ANSI (PT_STRING8) , or for Unicode it would be PR_TRANSPORT_MESSAGE_HEADERS_W ("http://schemas.microsoft.com/mapi/proptag/0x007D001F").
     
    The MAPI property tag you'd use to create the x-header would be : "http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/BookingType"
     
    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "gr_gr" <=?utf-8?B?Z3JfZ3I=?=> wrote in message news:08ecce0a-be0a-4d42-9bbd-7d1691b8abde...
    Hi,

    I am using outlook 2007 and I am trying to set and get properties through PropertyAccessor.SetProperty and PropertyAccessor.GetProperty.

    This works for a normal appointment item when created for self. But when attendees are added to the appointment item then the properties are not copied to the attendees appointment (not only in the appointment invitation mail but in the appointment itself), though the properties are added to the self.  I checked it through OutlookSpy.

    Here is the code that I use for set and get properties. Should I use a different GUID than this "00020329-0000-0000-C000-000000000046" ?

     public static bool CreateExtendedProperty(object outlookItem, object value)
            {
                try
                {
                    
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        (outlookItem as Outlook.AppointmentItem).PropertyAccessor.SetProperty(prop, value);
                    }
                 return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in adding assignment data to the outlook item. " + ex.Message);
                    return false;
                }


            }



    public static object GetExtendedPropertyValue(object outlookItem, string property)
            {
                try
                {
                   
                    object result = null;
                    if (outlookItem is Outlook.AppointmentItem)
                    {
                        string prop = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/BookingType";
                        result = (outlookItem as Outlook.AppointmentItem).PropertyAccessor.GetProperty(prop);
                    }
                    

                    return result;
                }
                catch (Exception ex)
                {
                    return null;
                }
            }

    -Geetha

    Ken Slovak MVP - Outlook
    Wednesday, February 2, 2011 3:18 PM
  • Hi Ken

    I have attempted using http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/<MyProperty>, and as mentioned it is included in the PS_INTERNET_HEADERS of the recipients email message.  When the recipient replys to the message the property and value are lost. 

    I need to explicitly state the clients may and may not be using exchange and or my addin.

    Much like many other people, I have a requirement where I want to tag a message with data "metadata", that I can interrogate when I receive a reply to the said message.  Specifically I want to route the email to the appropriate mailbox depending on the metadata the mailitem has been tagged with.

    My approach has been to use an outlook addin to capture the applicable metadata, I envisage that either through a Server side rule or if need be an Exchange RoutingAgent I will be able to intercept the return email and send it to the relevant mailbox.  Can you confirm that this is possible?

    Kind regards

    Sheldon

    Thursday, April 5, 2012 6:23 AM
  • Unless your recipients are using your addin or some such code there is no way at all that their replies will have any metadata that you want.
     
    Internet headers you add as x-headers are meaningless to Outlook, Exchange or MAPI. They are just text within a string property (PR_TRANSPORT_MESSAGE_HEADERS). The metadata content is meaningful only to you.

    --
    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
     
     
    "Sheldon Northmore" <=?utf-8?B?U2hlbGRvbiBOb3J0aG1vcmU=?=> wrote in message news:35e34b6f-edc0-44e0-97c7-11dfaeb06d64...

    Hi Ken

    I have attempted using http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/<MyProperty>, and as mentioned it is included in the PS_INTERNET_HEADERS of the recipients email message.  When the recipient replys to the message the property and value are lost. 

    I need to explicitly state the clients may and may not be using exchange and or my addin.

    Much like many other people, I have a requirement where I want to tag a message with data "metadata", that I can interrogate when I receive a reply to the said message.  Specifically I want to route the email to the appropriate mailbox depending on the metadata the mailitem has been tagged with.

    My approach has been to use an outlook addin to capture the applicable metadata, I envisage that either through a Server side rule or if need be an Exchange RoutingAgent I will be able to intercept the return email and send it to the relevant mailbox.  Can you confirm that this is possible?

    Kind regards

    Sheldon


    Ken Slovak MVP - Outlook
    Thursday, April 5, 2012 2:39 PM
  • Hi Ken

    Thanks for your reply,  from your answer I understand that the metadata is meaningful only to consumers that make use of my addin. 

    The metadata  is only intended to be be processed when the email has been replied too.  Is there anyway in persisting this data, other than in the body or subject of the email?  Of course these 2 locations can be tampererd with, that is why I was looking at the potential of using the headers. 

    In essense User A sends email with metadata tag Project X, geographic region Y, when the email is returned I would like to Interrogate this tag and then automatically forward the email to the appropriate mailbox\s

    Are there any other solutions you would recommend?

    Kind regards

    Sheldon

    Tuesday, April 10, 2012 6:08 AM
  • maybe you could try to store that metadata on your side (add-in/outlook) - create dictionary with conversationid or conversationindex that maps to your metadata and inspect mails on arrival checking that property and retrieving metadata if exists? Of course first verify if property that you want to use is immune to changes if subject changes, etc.
    Tuesday, April 10, 2012 10:25 AM
  • There is no way to round-trip data as you want, unless code on the receiving side takes any incoming data and puts it in any return email. You could try what Damian suggested, there really isn't much else you can do unless you have code running on both sides of the equation.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Sheldon Northmore" <=?utf-8?B?U2hlbGRvbiBOb3J0aG1vcmU=?=> wrote in message news:55e95df2-b61b-4f8d-b337-7966dc812c1b...

    Hi Ken

    Thanks for your reply,  from your answer I understand that the metadata is meaningful only to consumers that make use of my addin. 

    The metadata  is only intended to be be processed when the email has been replied too.  Is there anyway in persisting this data, other than in the body or subject of the email?  Of course these 2 locations can be tampererd with, that is why I was looking at the potential of using the headers. 

    In essense User A sends email with metadata tag Project X, geographic region Y, when the email is returned I would like to Interrogate this tag and then automatically forward the email to the appropriate mailbox\s

    Are there any other solutions you would recommend?

    Kind regards

    Sheldon


    Ken Slovak MVP - Outlook
    Tuesday, April 10, 2012 6:47 PM
  • Thanks Damian and Ken....I had already gone ahead with a similar solution to Ken's suggested solution using and identifiable tag appended to the message body, not as robust as I would have liked but as needs must.


    Thanks again.

    Wednesday, April 11, 2012 12:46 AM