outlook - C# Problems getting a specific named MAPI property from a .msg -


i'm having similar problem this question in getting pair of "custom" mapi properties mailitem in c# console app, twist works locally not on server.

the 2 properties pr_serverid , pr_msgid , both available on mailitems when inspected via mfcmapi, i'm accessing them follows:

messagedetails.pr_serverid = message.propertyaccessor.getproperty("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-c000-000000000046}/pr_serverid").tostring();  messagedetails.pr_msg_id = message.propertyaccessor.getproperty("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-c000-000000000046}/pr_msgid").tostring(); 

where message of type outlook.mailitem. when run locally (from built exe or in debug) works on separate server exact same message fails with:

15:17:26 error getting getting mapi properties stub:  system.applicationexception: system.runtime.interopservices.comexception (0x8004010f):  property "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-c000-000000000046}/pr_serverid" unknown or cannot found. 

before this, retrieving 2 "standard" mapi properties (pr_creator_name , pr_internet_message_id) same item mailitem accessible.

the dasl properties shown in mfcmapi identical between 2 servers , local machine , both running outlook 2010 , accessing mailitem invoking outlook session.

the thing think of outlook unable recognise custom properties without configuration that's missing on remote server(s), outlook have have property configured @ namespace level recognised if identified dasl?

edit: additional information on mail items: mails "stubs" downloaded archive system, 2 attributes provide identifier "full" message content. i'm downloading stub remote server, saving locally , accessing each stub in set using:

outlook.namespace ns = _outlookapplication.getnamespace("mapi"); object item = _outlookapplication.session.openshareditem(messagedetails.filepath) outlook.mailitem message = (outlook.mailitem)item; 

and attempting add 2 properties messagedetails object getting properties message.

edit 2: i've noticed when retrieving properties on "fresh" host, security prompt "a program trying access e-mail address information stored in outlook" when access custom properties not when access subjectline/sender etc. standard properties. seems indicate there these custom properties "different" when accessed via com interop using outlook. nevermind, default protection on calling propertyaccessor.getproperty.

answer: dmitry spot on , have marked response answer, properties not accessible because had never been created on store. user machines these have been created because @ point "archived" mails remote store , set custom properties on stubs left in our mail boxes. on servers had never been done added option "first run" creates dummy object, sets 2 empty custom properties on it, saves deletes it. subsequent runs able access properties using propertyaccessor.getproperty.

outlook object model assumes pt_unicode / pt_string8 type properties in "string" namespace. type in case pt_long (0x0003).

as test, can install redemption , try following script outlookspy (click script, paste script, click run)

  set session = createobject("redemption.rdosession")   session.mapiobject = application.session.mapiobject   set msg = session.getmessagefrommsgfile("c:\temp\yourmsg.msg")   msgbox msg.fields("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-c000-000000000046}/pr_serverid/0x00000003") 

update try following script in outlookspy on machine code fails. when imessage window pops up, see named properties?

set msg = application.session.openshareditem("c:\temp\yourmsg.msg") browseobject(msg.mapiobject) 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -