A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 21st 09, 08:48 PM posted to microsoft.public.outlook.program_forms
Michael Schmitz
external usenet poster
 
Posts: 11
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?

Hello NG,

I am very new to Outlook2007 and VSTO (Visual Studio 2008)

in a mail i have a user defined Named Property "UID"

the DASL is
http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/UID
(I used outlookspy to get this)

At the moment I'am looping through all ItemProperties and search for
a Property with the Name "UID" to read/write to that property.

Is their a better way to directly access such a user defined property?

maybe something like: string foo = (string) mail.Properties["UID"]; ?
I've read something about the Outlook.PropertyAccessor, but I'am not
aure if this is the normal way to read/write a user defiened field.


below is a snippet of a csharp code I'am using at the moment.
CodeSnippet:
############################################
private void On_btnSave_Click(object sender, EventArgs e)
{
Outlook.MailItem mail;
Outlook.ItemProperties properties;

try
{

if (this.OutlookItem is Outlook.MailItem)
{
mail = (Outlook.MailItem)this.OutlookItem;
properties = mail.ItemProperties;

// aender den Betreff wie gewuenscht ab
mail.Subject = this._txt1.Text;

// suche das UID Propertie!
foreach (Outlook.ItemProperty xProperty in properties)
{
if (xProperty.Name == "UID")
{
xProperty.Value = this._txt2.Text;

break;
}
}
mail.Save();
}
}
finally
{
mail = null;
properties = null;
}
}


  #2  
Old April 21st 09, 09:05 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?

You should be able to use ItemProperties.Item("UID") or
UserProperties.Item("UID").

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Michael Schmitz" wrote in message
...
Hello NG,

I am very new to Outlook2007 and VSTO (Visual Studio 2008)

in a mail i have a user defined Named Property "UID"

the DASL is
http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/UID
(I used outlookspy to get this)

At the moment I'am looping through all ItemProperties and search for
a Property with the Name "UID" to read/write to that property.

Is their a better way to directly access such a user defined property?



  #3  
Old April 21st 09, 10:09 PM posted to microsoft.public.outlook.program_forms
Michael Schmitz
external usenet poster
 
Posts: 11
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?


"Sue Mosher [MVP]" schrieb im Newsbeitrag
...
You should be able to use ItemProperties.Item("UID") or
UserProperties.Item("UID").


Thanks Sue that was the right hint to point me to a direction.
My code looks now like this, I guess the above only works for
VB.NET?

Regards

Michael (I got your Book allready )!

codesnipet:
###########################################

mail = (Outlook.MailItem)this.OutlookItem;
this._txt1.Text = "Read:" + mail.Subject;
try
{
this._txt2.Text = mail.ItemProperties["UID"].Value.ToString();
}
catch
{
this._txt2.Text = "???";
}



  #4  
Old April 22nd 09, 12:49 AM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?

I have no idea. I write code only for VB languages. Your best reference is
the PIA documentation on MSDN; perhaps the example at
http://msdn.microsoft.com/en-us/library/bb608929.aspx will be helpful.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Michael Schmitz" wrote in message
...

"Sue Mosher [MVP]" schrieb im Newsbeitrag
...
You should be able to use ItemProperties.Item("UID") or
UserProperties.Item("UID").


Thanks Sue that was the right hint to point me to a direction.
My code looks now like this, I guess the above only works for
VB.NET?

Regards

Michael (I got your Book allready )!

codesnipet:
###########################################

mail = (Outlook.MailItem)this.OutlookItem;
this._txt1.Text = "Read:" + mail.Subject;
try
{
this._txt2.Text = mail.ItemProperties["UID"].Value.ToString();
}
catch
{
this._txt2.Text = "???";
}





  #5  
Old April 22nd 09, 02:17 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?

This C# code:

mail.ItemProperties["UID"] or mail.UserProperties["UID"]

is the equivalent of the VB type code:

mail.UserProperties.Item("UID") or mail.ItemProperties.Item("UID")

--
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


"Sue Mosher [MVP]" wrote in message
...
I have no idea. I write code only for VB languages. Your best reference is
the PIA documentation on MSDN; perhaps the example at
http://msdn.microsoft.com/en-us/library/bb608929.aspx will be helpful.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Michael Schmitz" wrote in message
...

"Sue Mosher [MVP]" schrieb im Newsbeitrag
...
You should be able to use ItemProperties.Item("UID") or
UserProperties.Item("UID").


Thanks Sue that was the right hint to point me to a direction.
My code looks now like this, I guess the above only works for
VB.NET?

Regards

Michael (I got your Book allready )!

codesnipet:
###########################################

mail = (Outlook.MailItem)this.OutlookItem;
this._txt1.Text = "Read:" + mail.Subject;
try
{
this._txt2.Text = mail.ItemProperties["UID"].Value.ToString();
}
catch
{
this._txt2.Text = "???";
}






  #6  
Old April 22nd 09, 07:27 PM posted to microsoft.public.outlook.program_forms
Michael Schmitz
external usenet poster
 
Posts: 11
Default What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Object using VSTO?


"Ken Slovak - [MVP - Outlook]" schrieb im Newsbeitrag
...
This C# code:

mail.ItemProperties["UID"] or mail.UserProperties["UID"]

is the equivalent of the VB type code:

mail.UserProperties.Item("UID") or mail.ItemProperties.Item("UID")


Thanks, thats what i thought



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Property tags - what happens if... (Rename of user defined field) Bert_Bert[_2_] Outlook and VBA 13 September 1st 08 02:48 PM
How to add a user defined field to Redemption RDOContactItem object? CataGeek Add-ins for Outlook 3 July 10th 08 12:09 AM
User Defined Field type property PocketRocket Outlook - Using Contacts 1 December 15th 07 12:43 AM
Accessing named property using outlook object model AtulSureka Outlook - Using Forms 4 December 1st 06 05:06 PM
How to create a user-defined field in vsto [email protected] Outlook - Using Forms 4 September 18th 06 03:55 PM


All times are GMT +1. The time now is 12:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.