Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook Program Addins
Outlook 2003 Word as Editor and .NET forms
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="rob_tt08, post: 4814627"] Ken, Here is the code we are using to set the User Properties. The variable _emails is a class level List<Outlook.MailItem>. It is being cleared and set to null when we are finished with it. I have previously tried changing the code to avoid using the list in case the mailitems being in a .NET collection was interfering somehow, but this did not help. The user properties are being added to the folder using the parameter on UserProperties.Add which tells it to add the property to the folder if required (except for SetIDProperty as these are not meant to be available as folder columns), but the problem is happening even after the properties have been added for other mail items successfully. When I check the value of a property immediately after adding it, it is correct. It just doesn't show up in the folder unless the user opens an inspector and saves it manually. Thank you for your assistance with this. // Loop through the mail items foreach (Outlook.MailItem mailItem in _emails) { // Other code ... // Check save first mailItem.Save(); if (_emailIn) EmailTRACERManager.Manager.MAPIHelper.SetIDProperty(mailItem, EmailTRACERManager.UPReceivedID, matterID); //We are logging an item with Register Only and need all properties EmailTRACERManager.Manager.MAPIHelper.SetBooleanProperty(mailItem, EmailTRACERManager.UPLogged, true); EmailTRACERManager.Manager.MAPIHelper.SetTextProperty(mailItem, EmailTRACERManager.UPProject, this.MatterName); //We have to save the email if the properties are to stay. mailItem.Save(); } public void SetBooleanProperty(Outlook.MailItem mailItem, string propertyName, bool boolValue) { try { Outlook.UserProperty prop = null; // Attempt to get the property, if it exists. if (mailItem.UserProperties[propertyName] == null) { //The property did not exist, add it. prop = mailItem.UserProperties.Add(propertyName, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olYesNo, true, System.Reflection.Missing.Value); } mailItem.UserProperties[propertyName].Value = boolValue; } catch (Exception ex) { EmailTRACERManager.Manager.LogError(ex.Message + " " + ex.StackTrace); } } public void SetIDProperty(Outlook.MailItem mailItem, string propertyName, Int64 idValue) { try { Outlook.UserProperty prop = null; // Attempt to get the property, if it exists. if (mailItem.UserProperties[propertyName] == null) { //The property did not exist, add it. prop = mailItem.UserProperties.Add(propertyName, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText); } mailItem.UserProperties[propertyName].Value = idValue.ToString(); } catch (Exception ex) { EmailTRACERManager.Manager.LogError(ex.Message + " " + ex.StackTrace); } } public void SetTextProperty(Outlook.MailItem mailItem, string propertyName, string textValue) { try { Outlook.UserProperty prop = null; // Attempt to get the property, if it exists. if (mailItem.UserProperties[propertyName] == null) { //The property did not exist, add it. prop = mailItem.UserProperties.Add(propertyName, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, true, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText); } mailItem.UserProperties[propertyName].Value = textValue; } catch (Exception ex) { EmailTRACERManager.Manager.LogError(ex.Message + " " + ex.StackTrace); } } [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Outlook Newsgroups
Outlook Program Addins
Outlook 2003 Word as Editor and .NET forms
Top