By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,601 Members | 1,528 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,601 IT Pros & Developers. It's quick & easy.

Windows Address Book API: Setting Email Addresses

P: 1
Hi All,

I am using the WAB C++ API to create some contacts in the address book. I am having a problem setting the email list property so I'm hoping somebody has used this before and can help me. Here is my code...

Expand|Select|Wrap|Line Numbers
  1. SLPSTRArray emailArray;
  2. LPSTR emails[2] = {"", ""};
  3. emailArray.cValues = 2;
  4. emailArray.lppszA = emails;
  5. aPropsMesg[31].ulPropTag = PR_CONTACT_EMAIL_ADDRESSES;
  6. aPropsMesg[31].Value.MVszA = emailArray;
When I check the entry created in the WAB, the PR_CONTACT_EMAIL_ADDRESSES property contains 2 strings as expected however they are not the correct strings. Instead all I see is 2 strings of what looks like Chinese or Japanese text.
Does anyone have any idea what may be wrong?

Thanks in advance,
Aug 9 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Probably it's here:

LPSTR emails[2] = {"", ""};
Two things.

1) a literal is not a LPSTR. It is an LPCSTR. If the string need to be modifed you will crash.
2) You should be using LPTSTR or LPCTSTR (inthe case of a literal). This is the standard TCHAR map used by Windows to build for either ASCII or Unicode. It could well be your control you use the check the property is expected a Unicode string.

Expand|Select|Wrap|Line Numbers
  1. LPCTSTR emails[2] = {TEXT(""), TEXT("")};
and build with the character set property set to Unicode.
Aug 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.