setting recipient name when creating a message via IMAPIFolder::CreateMessage

Tech-Archive recommends: Fix windows errors by optimizing your registry




This is for PocketPC. I posted in the pocketpc.developer newsgroup and MSDN forum but no reply so I posted it here. Hope to have some hints.

I successfully created a message in Sent Items folder using the following code.

However, I want Pocket Outlook to show the recipient name (instead of the recipient number) when the message is displayed in the list. How can I do that? Is there any flag that tells Pocket Outlook to look up the address book and maps the recipient number to the contact name and display the contact name instead, or must I set the recipient name manually? I mean, what property should I add to the property array when creating the message?

LPMESSAGE pmsg;

hr = currentFolder->CreateMessage(NULL, 0, &pmsg); if (hr!= S_OK) return hr;

//add recipients
SPropValue propRecipient[3]; ZeroMemory(&propRecipient, sizeof(propRecipient)); propRecipient[0].ulPropTag = PR_RECIPIENT_TYPE; propRecipient[0].Value.l = MAPI_TO; propRecipient[1].ulPropTag = PR_ADDRTYPE; propRecipient[1].Value.lpszW = _T("SMS"); propRecipient[2].ulPropTag = PR_EMAIL_ADDRESS; propRecipient[2].Value.lpszW = msgRecipient;

ADRLIST adrlist; adrlist.cEntries = 1; adrlist.aEntries[0].cValues = 3; adrlist.aEntries[0].rgPropVals = (LPSPropValue)(&propRecipient); hr = pmsg->ModifyRecipients(MODRECIP_ADD, &adrlist);

//change other properties
SPropValue props[5]; //add one more element to hold the contact name
ZeroMemory(&props, sizeof(props));

//PR_SUBJECT points to SMS contents
props[0].ulPropTag = PR_SUBJECT; props[0].Value.lpszW = msgSubject;

//type of message. Without this it'll be an email
props[1].ulPropTag = PR_MESSAGE_CLASS;
props[1].Value.lpszW = TEXT("IPM.SMStext");

//mark message as read
props[2].ulPropTag = PR_MESSAGE_FLAGS; props[2].Value.ul = MSGFLAG_READ | MSGFLAG_FROMME | MSGFLAG_UNSENT;

//set delivery time to system time
SYSTEMTIME stNow;
FILETIME ftNow;
GetSystemTime(&stNow);
SystemTimeToFileTime(&stNow, &ftNow)
props[3].ulPropTag = PR_MESSAGE_DELIVERY_TIME;
props[3].Value.ft = ftNow;

//set contact name. What should I assign to ulPropTag
props[4].ulPropTag = ???;
props[4].Value.lpszW = TEXT("Contact Name goes here");

//assign the property to the message
hr = pmsg->SetProps(sizeof(props) / sizeof(props[0]), (LPSPropValue)&props, NULL);

One of the moderators on MSDN forum states that he has tried and did not successfully set the property. Any ideas how I can do it? Thanks.

[Original thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3852632&SiteID=1]


.



Relevant Pages

  • setting recipient name when creating a message via IMAPIFolder::CreateMessage
    ... I want Pocket Outlook to show the recipient name when the message is displayed in the list. ... //set delivery time to system time ... FILETIME ftNow; ... One of the moderators on MSDN forum states that he has tried and did not successfully set the property. ...
    (microsoft.public.pocketpc.developer)
  • Pocket PC 2003 MAPI Attachments
    ... Pocket PC 2003 environment. ... if I open the message in the Pocket PC Inbox before it is ... the recipient correctly the next time I synchronise with the POP3 server. ... MSG SOURCE WHERE ATTACHMENT NOT SENT PROPERLY: ...
    (microsoft.public.pocketpc.developer)
  • GetRecipientTable in Pocket PC...
    ... I'm a eVC brazilian developer, ... how to get TO, CC, BCC etc from messages in the oulook of ... I'm developing to Pocket PC 2002/2003 and trying to use the ... get the recipient name and address of the messages of the ...
    (microsoft.public.pocketpc.developer)
  • GetRecipientTable in Pocket PC...
    ... I'm a eVC brazilian developer, ... how to get TO, CC, BCC etc from messages in the oulook of ... I'm developing to Pocket PC 2002/2003 and trying to use the ... get the recipient name and address of the messages of the ...
    (microsoft.public.windowsce.app.development)
  • GetRecipientTable in Pocket PC...
    ... I'm a eVC brazilian developer, ... how to get TO, CC, BCC etc from messages in the oulook of ... I'm developing to Pocket PC 2002/2003 and trying to use the ... get the recipient name and address of the messages of the ...
    (microsoft.public.windowsce.embedded.vc)