What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje

Status
Not open for further replies.
M

Michael Schmitz

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;

}

}
 
D

Dmitry Streblechenko

Have youi looked at MailItem.PropertyAccessor?

Dmitry Streblechenko (MVP)

-

"Michael Schmitz" <spam@gmx.net> wrote in message

news:O4uUHxrwJHA.956@TK2MSFTNGP03.phx.gbl...
> 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;
> }
> }

>
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 5
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 11
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
N Disable Auto Read Receipts sent after using Advanced Find Using Outlook 4
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
N Separate Read Layout Editing Outlook VBA and Custom Forms 0
A Read and Write to Text File Outlook VBA and Custom Forms 1
L Email Read and Delete Outlook VBA and Custom Forms 4
A Separate Read Layout Outlook VBA and Custom Forms 4
M Making Subject field writable (disable Read Only) Outlook VBA and Custom Forms 2
M How can I determine which user read an email Exchange Server Administration 4
Diane Poremsky Mark Sent Items as Read After Copying with a Rule New Slipstick.com Articles 0
Diane Poremsky Edit and Save Outlook's Read-Only Attachments New Slipstick.com Articles 0
Rupert Dragwater Some mailboxes show deleted items as not read Using Outlook 5
K cant read email or open attachement Using Outlook 0
R Reply marks read message as unread Using Outlook 1
T Outlook 2013 either fails to mark messages as read or marks them as read, then un-marks them. Using Outlook 1
Mary B VBscript: Need to copy every email to a folder & mark that copy as read Outlook VBA and Custom Forms 5
Mary B Outlook 2013: Rule for copying new email to folder & marking that copy as read Using Outlook 1
M Sorting messages by read/unread status Using Outlook 8
C Mark all incoming emails as read Outlook VBA and Custom Forms 3
FirefIy Marking message read only if replied to the message or Ctrl+Q. Possible? Using Outlook 1
A give User Read Only access to secondary mailbox in Exchange 2010 via AD Exchange Server Administration 1
M How do I mark emails already received as read when I get a second, different email based on subject? Outlook VBA and Custom Forms 3
JR Ryan Outlook marks all as "Read" issue Exchange Server Administration 2
R Cannot read Chinese message after import Using Outlook 2
T Saving Outlook 2010 email with attachments but read the email without Outlook Using Outlook 2
M Oh please read---> Extracting email web leads on to excel spread sheet Using Outlook 3
S Outlook Custom form - selecting text in read page Using Outlook 0
C In need of VBA code to read / parse HTML - Outlook emails Using Outlook 0
A Can't read my mails if they are on a folder... Using Outlook 0
M Unable to read HTML Using Outlook 2
J Cannot read incoming emails Using Outlook 2
P Custom field is read only Using Outlook 1
C (Read, not read) receipt "subject" problem Using Outlook 8
S iCloud Outlook Calendar is read only Using Outlook 1
Z Mark moved copies as "Read" Using Outlook 19
M Can't read invitations to appointments Using Outlook 1
M TO field on Read Page not resolving Using Outlook 3
G How to make outlook show as unread messages I read in my mobile ph or tablet Using Outlook 1
J From column changes when message is read Using Outlook 1
Z "Mark All as Read" in Outlook 2007 extremely slow Using Outlook 1
S Duplicate Read Receipt Using Outlook 4
K Read, unread, i'm losing clients! Using Outlook 1
H mark as read per folder options Using Outlook 1
G Editing the Read Receipt Using Outlook 1
S Block read receipt when outlook is configured to Exchange server Using Outlook 0
J Mail read in OWA won't appear in Outlook Exchange Server Administration 1
P mails in my inbox of outlook 2007 tend to go missing after I read them Using Outlook 14
P Read receipts and preview panes Using Outlook 1
Similar threads


















































Top