> Offhand I'm not sure but I'd try 2 different things. First see if setting
> the DisplayFormat argument instead of setting it to missing helps. Second,
> see if passing the email item object by reference makes any difference.
>
> --
> 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>
>
> "rob_tt08" <robtt08[ at ]discussions.microsoft.com> wrote in message
> news:6FDA50A0-C391-4E1A-B6FF-D277EFEB7713[ at ]microsoft.com...
> > 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);
> > }
> > }
> >
>
>