Custom Properties in Outlook

Last post 08-09-2011, 4:36 AM by saqib.razzaq. 1 replies.
Sort Posts: Previous Next
  •  08-08-2011, 9:13 AM 321082

    Custom Properties in Outlook .NET

    Hello, I am trying to write custom properties to an .msg file using Aspose.Network that I could read from within an Outlook add-in using the Outlook object model.  My code is based on this post http://www.aspose.com/community/forums/2/275051/custom-properties-in-an-outlook-form/showthread.aspx.

    Using this code I get an error trying to open the message from Outlook, a dialog window opens that says 'Cannot read the item.'  This error happens on machines that do not have our Outlook add-in installed, and if I remove the code for adding custom properties the msg file opens correctly, so I think the problem is in that code.

    Here is the code I am using to write a custom property -

     

                            MapiPropertyCollection namedProperties = message.NamedProperties;
                            MapiNamedPropertyMappingStorage mappingStorage = message.NamedPropertyMapping;
     
                            Guid PS_MAPI = Guid.NewGuid();
                            Guid PS_PUBLIC_STRINGS = Guid.NewGuid();
     
                            MapiProperty stringProperty = new MapiProperty(mappingStorage.GetNextAvailablePropertyId(MapiPropertyType.PT_LONG), Encoding.Unicode.GetBytes(fileInfo.FileId.ToString()));
                            message.SetProperty(stringProperty);
     
                            string stringNameId = "fileInfo";
                            mappingStorage.AddNamedPropertyMapping(stringProperty, stringNameId, PS_PUBLIC_STRINGS);

    Is there another way that I should be doing this?  I am using Aspose.Network version 6.7.

     

    Thanks,

    Aaron

    Filed under: .MSG
     
  •  08-09-2011, 4:36 AM 321277 in reply to 321082

    Re: Custom Properties in Outlook .NET

    Hi Aaron,

    Thank you for inquiry.

    Please use "MapiPropertyType.PT_STRING8" in the below line:
    MapiProperty stringProperty = new MapiProperty(mappingStorage.GetNextAvailablePropertyId(MapiPropertyType.PT_LONG), Encoding.Unicode.GetBytes(fileInfo.FileId.ToString()));

    This will fix your issue.


    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
View as RSS news feed in XML