Newbie question on kopano python
-
I try to access the email address attribute in contact folder
1 import kopano 2 3 from MAPI.Tags import * 4 5 server = kopano.Server() 6 7 store = server.user('linuxadmins').store 8 9 contacts = store.contacts 10 11 print(contacts.count) 12 13 for item in contacts: 14 print(item) 15 for prop in item: 16 print(prop, prop.value)
It seems there are not MAPI Tags for the E-Mail Addresses:
Item(Binary-People) (Property(PR_MESSAGE_CLASS_W), u'IPM.Contact') (Property(PR_SENSITIVITY), 0L) (Property(PR_SUBJECT_W), u'Binary-People') (Property(PR_SUBJECT_PREFIX_W), u'') (Property(PR_DISPLAY_BCC_W), u'') (Property(PR_DISPLAY_CC_W), u'') (Property(PR_DISPLAY_TO_W), u'') (Property(PR_MESSAGE_FLAGS), 1L) (Property(PR_MESSAGE_SIZE), 2347L) (Property(PR_PARENT_ENTRYID), '\x00\x00\x00\x00\x1c\xe5:q&8B\x02\x89\xb2V\xe4\xb2\xae\x88\xdd\x01\x00\x00\x00\x03\x00\x00\x00\xbae{\x12\xee\xa8J\xd2\xa61\xe5\x0b;\x99\x80\x98\x00\x00\x00\x00') (Property(PR_MESSAGE_RECIPIENTS), None) ... (Property(address:32896), u'Binary-People (matt@binary-people.org)') (Property(address:32898), u'SMTP') (Property(address:32899), u'matt@binary-people.org') (Property(address:32900), u'matt@binary-people.org') ...
How can I access the email address attributes and how can i loop over all email addresses of a contact??
BTW: I am absolutely new to python. Is there a collection of examples available somewhere?
greetings
Mathias -
i use this:
prop_MAIL1=str(item.get_value('address:32899')) if prop_MAIL1 == "None": prop_MAIL1="" prop_MAIL2=str(item.get_value('address:32915')) if prop_MAIL2 == "None": prop_MAIL2="" prop_MAIL3=str(item.get_value('address:32931')) if prop_MAIL3 == "None":
-
Thanks for the answer
I have already feared that this is the solution. But why are the tags missing? Are they hiding in another library? I have used the PHP binding before and have encountered similar problems. The APIs do not make a very mature impression.
-
I found this Document:
http://interoperability.blob.core.windows.net/files/MS-OXPROPS/[MS-OXPROPS].pdf
Here you can find all Attribute indexes of an Exchange server. For example:
PidLidEmail2EmailAddress
Property long ID (LID): 0x00008093This is in decimal 32915
So, now I have a way to find proper Indexes
-
Examples can be found in the Kopano core repository and another location in the repository.
A contact can have multiple email addresses, so in WebApp there is some logic to figure out which email address is set.
-
prop_MAIL1=str(item.get_value('address:32899')) if prop_MAIL1 == "None": prop_MAIL1=""
note that you can write this shorter as:
prop_MAIL1 = item.get_value(‘address:32899’) or “”
-
@mdoehle said in Newbie question on kopano python:
I found this Document:
http://interoperability.blob.core.windows.net/files/MS-OXPROPS/[MS-OXPROPS].pdf
Here you can find all Attribute indexes of an Exchange server. For example:
PidLidEmail2EmailAddress
Property long ID (LID): 0x00008093This is in decimal 32915
So, now I have a way to find proper Indexes
yeah, we didn’t get around to adding all the common pidlids to eg MAPI.Tags yet. so you’ll have to define them yourself for now, eg as follows:
PidLidEmail2EmailAddress = “PT_STRING8:PSETID_Address:0x8093”
and then you can do:
address = item.get_value(PidLidEmail2EmailAddress) or “”
yeah, python-kopano is still pretty young at this point (3 years?), and we are adding things all the time. creating an abstraction layer above MAPI is not an easy task…
-
@mark-dufour
thanks -
Thanks for the helpful answers. Now I have just to learn a bit more python and then I will build beautiful plugins. ;-)
Hope to see some of you at the Python Workshop in Arnheim…
greetings
Mathias