Set the contact webpage in python

Hi,

how to set the contact webpage. The tags PR_BUSINESS_HOME_PAGE / PR_BUSINESS_HOME_PAGE_W and PROP_TAG( PT_STRING8, 0x802B ) didn’t work.

import kopano
from MAPI.Tags import *

server = kopano.Server(
...
)

user = server.user('user1')
contacts = user.store.folder('Contacts')

item = contacts.create_item(subject='', message_class='IPM.Contact')
item.set_value(PR_DISPLAY_NAME_W,u'test1')
item.set_value(PR_BUSINESS_TELEPHONE_NUMBER,"123")
item.set_value(PR_BUSINESS_HOME_PAGE_W,u'www.test1.com')

Hi,

I see you are not importing the mapi tags, try to add this below import kopano.

from MAPI.Tags import *

Kind regards,

Mark

Sorry in my original script the import exists and there are no errors but the webpage are not set. I’ve added the import above.

Kind regards

Hi,

This works for me.

import kopano
from MAPI.Tags import PR_DISPLAY_NAME_W, PR_BUSINESS_TELEPHONE_NUMBER, PR_BUSINESS_HOME_PAGE_W

server = kopano.Server()

user = server.user('kopano')
contacts = user.store.folder('Contacts')

item = contacts.create_item(message_class='IPM.Contact')
item.create_prop(PR_DISPLAY_NAME_W, u'test1')
item.create_prop(PR_BUSINESS_TELEPHONE_NUMBER, "123")
item.create_prop(PR_BUSINESS_HOME_PAGE_W, u'www.test1.com')

Kind regards,

Mark

The create_prop method does not work for me… Don’t no why. No errors but the fields are empty.

Which version of kopano are you using ?

8.4.6.0-0+9

I am running 8.5.81.276-0+31.1 but I see no reason why my code should not work at your side.

Ok thank you for your answers, I will test it on a clean installation.

I just tested on my live server on 8.5.0 it does work as well.

Kind regards,

Mark

yeah, the create_prop method did not always save the message, and I guess we fixed this for 8.5.

for 8.6 we are working on not needing any MAPI-level stuff for dealing with contact fields, so you could say, for example:

item = contacts.create_item(
name=u’test1’,
business_homepage=’…’,
business_phone=’…’,
)

I’ve tested again with kopano 8.5.81.224-0 amd64 and webapp 3.4.6.1225+7 on a debian 9.3.
The create_prop method works but the PR_BUSINESS_HOME_PAGE_W only displayed on the outlook client.
An indication error within the webapp frontend client?