none
UserProperties.Count is zero in .msg file in Outlook 2007 RRS feed

  • Question

  • hi, I am working with an Outlook 2007 addin developed in VS 2008. This addin adds some properties in the UserProperties collection while sending (in ThisAddin_Send() event) email using below code:
    newMail.ItemProperties.Add("ActivityID", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing).Value = "123456";

    After sending email, when I open the mailItem from SentItems folder I noticed that the Property "ActivityID" is available in the UserProperties collection.
     
    Then I copied the email from SentItems, pasted on my desktop, I got the email in a file (test.msg). When I open/double click on this file from my desktop, the email opens in Outlook window. In the NewInspector() event of the addin I checked that this Item does not contain the property "ActivityID" in the UserProperties collection.
    mailItem.UserProperties.Count
    
    This returns zero in the NewInspector() event. But I need the value of the property to do some work using it.
    Can anyone please let me know why this happens or if there is any solution to hold this?
    Thanks in advance...
    -Jahedur Rahman

    Wednesday, December 14, 2011 9:37 AM

Answers

  • Hi Jahedur.Rahman,

     

    Thanks for posting in the MSDN Forum.

     

    I reproduced your issue on my side. And I think UserProperties will never save to file when the MSG file has been saved. I tracked the item in debug and I never see any user properties in the UserProperties collection.

     

    I think if you need to export some value which are hidden in MSG file you can use “<input type=”hidden” name=”ddd” value=”xxx”>” in you mail’s html body.

     

    I hope what I said can help you.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Jahedur.Rahman Wednesday, December 21, 2011 8:47 AM
    Friday, December 16, 2011 3:11 AM
    Moderator

All replies

  • Hi Jahedur.Rahman,

     

    Thanks for posting in the MSDN Forum.

     

    I reproduced your issue on my side. And I think UserProperties will never save to file when the MSG file has been saved. I tracked the item in debug and I never see any user properties in the UserProperties collection.

     

    I think if you need to export some value which are hidden in MSG file you can use “<input type=”hidden” name=”ddd” value=”xxx”>” in you mail’s html body.

     

    I hope what I said can help you.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Jahedur.Rahman Wednesday, December 21, 2011 8:47 AM
    Friday, December 16, 2011 3:11 AM
    Moderator
  • Thanks Tom_Xu for your effort on this and providing another solution to incorporate my needs.

    I will try your suggestion, but can you please let me know how to read this hidden values from HTML? I mean do I need to search for the tags from the HTML Body? or there are some smart options to read through the collection of hidden input values.

    Thanks a lot...

    -Jahedur Rahman

    Friday, December 16, 2011 4:23 AM
  • Hi Jahedur,

     

    I would recommend you use Regex class to match the key words to retrieve the tags. More information for Regex please look http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx.

     

    I hope it can help you.

     

    If you have any questions, please feel free to let me know.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, December 20, 2011 10:58 AM
    Moderator
  • Thanks a lot Tom_Xu...
    Wednesday, December 21, 2011 8:47 AM