How to set a contact's emailaddress1, emailaddress2, emailaddress3?

  • Thread starter ryotyankou via OfficeKB.com
  • Start date
R

ryotyankou via OfficeKB.com

I want to update the contact's info or create new contact with emailaddress1,
emailaddress2 and emailaddress3. For new contact, i use IAddrBook::
CreateOneOff, it works great. But i don't know how to update the three
emailaddress, for example: user can set the following combine for three
emailaddresses.
1. None. No emailaddress will be set.
2. First only first emailaddress will be set.
3. Second //no need for explaination, right :)
4. Third
5. First && Second
6. First && Third
7. Second && Third
8. First, Second and Third
I tried to use SetProps and pass empty string in, the contact's emailaddress
will be empty, it's ok, but the associated entry in addressbook is still
there.
Do i need to DeleteEntries to remove it?
Another question, whether an IMessageStore can only have one Addressbook? I
don't quite understand the difference between GetDefaultDir and GetPAB.
(Default DIR and PAB).
Thanks in advance.
 
D

Dmitry Streblechenko

Are you setting these properties on teh IMailUser object returned by the OAB
address book provider or teh underlying IMessage in one of the contacts
folders?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

Take no care about which interface i used to set these properties, would you
please tell me how to update them to reach my purpose in both situations(the
IMailUser and IMessage). TIA.

Dmitry said:
Are you setting these properties on teh IMailUser object returned by the OAB
address book provider or teh underlying IMessage in one of the contacts
folders?
I want to update the contact's info or create new contact with
emailaddress1,
[quoted text clipped - 20 lines]
(Default DIR and PAB).
Thanks in advance.
 
R

ryotyankou via OfficeKB.com

Another questions, What's the difference between PAB and default Directory?
And whether a message store can only have one addressbook? Thank you.

Dmitry said:
Are you setting these properties on teh IMailUser object returned by the OAB
address book provider or teh underlying IMessage in one of the contacts
folders?
I want to update the contact's info or create new contact with
emailaddress1,
[quoted text clipped - 20 lines]
(Default DIR and PAB).
Thanks in advance.
 
D

Dmitry Streblechenko

? It makes all the difference in the world how you access these objects.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
ryotyankou via OfficeKB.com said:
Take no care about which interface i used to set these properties, would
you
please tell me how to update them to reach my purpose in both
situations(the
IMailUser and IMessage). TIA.

Dmitry said:
Are you setting these properties on teh IMailUser object returned by the
OAB
address book provider or teh underlying IMessage in one of the contacts
folders?
I want to update the contact's info or create new contact with
emailaddress1,
[quoted text clipped - 20 lines]
(Default DIR and PAB).
Thanks in advance.
 
D

Dmitry Streblechenko

IAddrBook::GetPAB returns the container used to keep the personal contacts
in.
IAddrBook::GetDefaultDir returns the entry id of the contains that is
selected by default when you open teh adderss book window.

Message stores do not have any address books. You are confusing address
books with one particular address book provider (OAB) that happens to use
IPM.Contact messages as a storage for its address book objects (IMailUser).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
ryotyankou via OfficeKB.com said:
Another questions, What's the difference between PAB and default
Directory?
And whether a message store can only have one addressbook? Thank you.

Dmitry said:
Are you setting these properties on teh IMailUser object returned by the
OAB
address book provider or teh underlying IMessage in one of the contacts
folders?
I want to update the contact's info or create new contact with
emailaddress1,
[quoted text clipped - 20 lines]
(Default DIR and PAB).
Thanks in advance.
 
R

ryotyankou via OfficeKB.com

OK, i will describe how did i get the contact info.
1. Use IAddrBook::GetSearchPath get SRowSet.
2. Use PropFindProp check SRowSet for PR_ENTRYID.
3. Use IAddrBook::OpenEntry open the entry id to get IABContainer.
4. Use IABContainer::GetContentsTable to get contact table.
5. Then i get wanted items in table and save their entry ids.
......after some operation, for example, show UI, let user make choose, etc.
In a word, i use the entry id find here to operate the contact.
My code is describe as follow:
1. ISession::OpenEntry(entry id) to get IMessage. //here should make a
conversion from CONTAB_ENTRYID to ENTRYID, for the entry id i got above is
CONTAB_ENTRYID, right??
2. use IMessage::SetProps to set
lNameId[0] = PID_LID_EMAIL1_ADDR_TYPE;// or EMAIL2/EMAIL3
lNameId[1] = PID_LID_EMAIL1_EMAIL_ADDRESS;
lNameId[2] = PID_LID_EMAIL1_ORIGINAL_DISPLAY_NAME;
lNameId[3] = PID_LID_EMAIL1_ORIGINAL_ENTRY_ID;//Use CreateOneOff create and
get entry id,
IMessage::SaveChange to save item.
This is only work for create new emailaddress and update existing
emailaddress.
For example, use want to set:
1. Before set:
we have : (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress1)
OK, we can update existing emailaddress.
2. Before set:
we have: (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress1), (e-mail address removed)
(emailaddress2)
OK we can create new.
3. Before set:
we have: (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress2)
That's mean we want to remove
emailaddress1.
ACTUAL RESULT IS: (e-mail address removed)(emailaddress1), (e-mail address removed)
(emailaddress2)
The code cannot work in situation 3.
In a word, i don't know how to remove existing emailaddress. Are we clear?

Dmitry said:
? It makes all the difference in the world how you access these objects.
Take no care about which interface i used to set these properties, would
you
[quoted text clipped - 12 lines]
 
R

ryotyankou via OfficeKB.com

My purpose is quite simple, as there is a contact(See how did i get its entry
id in other reply of this post), I Create an UI, user can change
Emailaddress1, Emailaddress2 and Emailaddress3 for this contact on the UI. If
user clear any one of them, that means user want to remove it in addressbook,
otherwise create new or update existing ones.

Dmitry said:
IAddrBook::GetPAB returns the container used to keep the personal contacts
in.
IAddrBook::GetDefaultDir returns the entry id of the contains that is
selected by default when you open teh adderss book window.

Message stores do not have any address books. You are confusing address
books with one particular address book provider (OAB) that happens to use
IPM.Contact messages as a storage for its address book objects (IMailUser).
Another questions, What's the difference between PAB and default
Directory?
[quoted text clipped - 10 lines]
 
R

ryotyankou via OfficeKB.com

Can you help me please, dmitry?
My purpose is quite simple, as there is a contact(See how did i get its entry
id in other reply of this post), I Create an UI, user can change
Emailaddress1, Emailaddress2 and Emailaddress3 for this contact on the UI. If
user clear any one of them, that means user want to remove it in addressbook,
otherwise create new or update existing ones.
IAddrBook::GetPAB returns the container used to keep the personal contacts
in.
[quoted text clipped - 9 lines]
 
D

Dmitry Streblechenko

So if you want to remove an address, you would need to delete the
appropriate properties from the IPM.Contact message using
IMessage::DeleteProps().

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
ryotyankou via OfficeKB.com said:
OK, i will describe how did i get the contact info.
1. Use IAddrBook::GetSearchPath get SRowSet.
2. Use PropFindProp check SRowSet for PR_ENTRYID.
3. Use IAddrBook::OpenEntry open the entry id to get IABContainer.
4. Use IABContainer::GetContentsTable to get contact table.
5. Then i get wanted items in table and save their entry ids.
.....after some operation, for example, show UI, let user make choose,
etc.
In a word, i use the entry id find here to operate the contact.
My code is describe as follow:
1. ISession::OpenEntry(entry id) to get IMessage. //here should make a
conversion from CONTAB_ENTRYID to ENTRYID, for the entry id i got above is
CONTAB_ENTRYID, right??
2. use IMessage::SetProps to set
lNameId[0] = PID_LID_EMAIL1_ADDR_TYPE;// or EMAIL2/EMAIL3
lNameId[1] = PID_LID_EMAIL1_EMAIL_ADDRESS;
lNameId[2] = PID_LID_EMAIL1_ORIGINAL_DISPLAY_NAME;
lNameId[3] = PID_LID_EMAIL1_ORIGINAL_ENTRY_ID;//Use CreateOneOff create
and
get entry id,
IMessage::SaveChange to save item.
This is only work for create new emailaddress and update existing
emailaddress.
For example, use want to set:
1. Before set:
we have : (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress1)
OK, we can update existing
emailaddress.
2. Before set:
we have: (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress1), (e-mail address removed)
(emailaddress2)
OK we can create new.
3. Before set:
we have: (e-mail address removed)(emailaddress1)
we want to set it as: (e-mail address removed)(emailaddress2)
That's mean we want to remove
emailaddress1.
ACTUAL RESULT IS: (e-mail address removed)(emailaddress1), (e-mail address removed)
(emailaddress2)
The code cannot work in situation 3.
In a word, i don't know how to remove existing emailaddress. Are we clear?

Dmitry said:
? It makes all the difference in the world how you access these objects.
Take no care about which interface i used to set these properties, would
you
[quoted text clipped - 12 lines]
(Default DIR and PAB).
Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top