UserProperties of MailItem object.

  • Thread starter Thread starter Sandeep K
  • Start date Start date
S

Sandeep K

I am adding one user property to an email in outlook 2007 using VSTO Addin.
When I close Outlook application It asks me, "Do you want to save changes?".

Can I avoid this prompt?

API I used :
prop = MailItem.UserProperties.Add("TestProp"
,
Outlook.OlUserPropertyType.olText
, false
,
Outlook.OlFormatText.olFormatTextText);
prop.Value = "Test";
 
Just a side note. I'm relatively new to Outlook programming but I got
into quite some trouble because of accessing the UserProperties
directly.
I would write:

UserProperties props = MailItem.UserProperties;
try
{
//Use props...
//...
MailItem.Save();
}
finally
{
Marshall.ReleaseCOMObject(props);
Marshall.ReleaseCOMObject(MailItem);
}
 
What problems did you have with your code?




Just a side note. I'm relatively new to Outlook programming but I got
into quite some trouble because of accessing the UserProperties
directly.
I would write:

UserProperties props = MailItem.UserProperties;
try
{
//Use props...
//...
MailItem.Save();
}
finally
{
Marshall.ReleaseCOMObject(props);
Marshall.ReleaseCOMObject(MailItem);
}
 
Back
Top