专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Windows Mobile

在已发送邮件中新建的短信怎么修改收件人信息

发布时间:2010-05-30 00:48:57 文章来源:www.iduyao.cn 采编人员:星星草
在已发送邮件中新建的短信如何修改收件人信息
我希望在已发送邮件中建立一条完整的信息,包括主题,收件人,时间等信息,不过修改收件人总是不成功,代码如下,望高手赐教

INT nRecipientCount = 1; //有1个联系人信息

INT nListBufSize = CbNewADRLIST(nRecipientCount); //计算3个联系人需要的存储空间

LPADRLIST pAddressList = NULL;

MAPIAllocateBuffer(nListBufSize, (LPVOID FAR *)&pAddressList); //分配空间

memset(pAddressList, 0, nListBufSize);


pAddressList->cEntries = 1; //0共有1个联系人信息

//设置To

INT nCurIndex = 0;

MAPIAllocateBuffer(sizeof(SPropValue) * 3, (LPVOID FAR *)&pAddressList->aEntries[nCurIndex].rgPropVals); //分配空间 memset(pAddressList->aEntries[nCurIndex].rgPropVals, 0, sizeof(SPropValue) * 3);

pAddressList->aEntries[nCurIndex].rgPropVals[0].ulPropTag = PR_RECIPIENT_TYPE;

pAddressList->aEntries[nCurIndex].rgPropVals[0].Value.ul = MAPI_TO; //表明是写到To


pAddressList->aEntries[nCurIndex].rgPropVals[1].ulPropTag = PR_ADDRTYPE;

pAddressList->aEntries[nCurIndex].rgPropVals[1].Value.LPSZ = _T("SMTP");


pAddressList->aEntries[nCurIndex].rgPropVals[2].ulPropTag = PR_EMAIL_ADDRESS;

CString str = recipients[0].sEmail;

pAddressList->aEntries[nCurIndex].rgPropVals[2].Value.LPSZ = recipients[0].sEmail.GetBuffer(0);

pAddressList->aEntries[nCurIndex].cValues = 3; //表明改联系人有3个属性要设置

HRESULT hr = m_pMessage->ModifyRecipients(MODRECIP_ADD, pAddressList);

for(INT i = 0; i < nRecipientCount; i++)

MAPIFreeBuffer(pAddressList->aEntries[i].rgPropVals);
MAPIFreeBuffer(pAddressList);

SPropValue props[3];
ZeroMemory(&props, sizeof(props));
// set the subject
props[0].ulPropTag = PR_SUBJECT;
props[0].Value.lpszW = L"这里可以成功设置主题";
//Set the sender
props[1].ulPropTag = PR_EMAIL_ADDRESS;
props[1].Value.lpszW = recipients[0].sEmail.GetBuffer(0);
//Set the message status to indicate this message needs
//enumeration. Vital property!
props[2].ulPropTag = PR_DISPLAY_NAME;
props[2].Value.lpszW = recipients[0].sEmail.GetBuffer(0);

// Finally set the properties on the message
hr = m_pMessage->SetProps(sizeof(props) / sizeof(props[0]), 
  (LPSPropValue)&props, NULL);

可以正确设置主题,不过收件人信息却设置不了,ModifyRecipients返回也正确,不知道是为什么

------解决方案--------------------
SPropValue props[3]; 
ZeroMemory(&props, sizeof(props)); 
// set the subject 
props[0].ulPropTag = PR_SUBJECT; 
props[0].Value.lpszW = L"这里可以成功设置主题"; 
//Set the sender 
props[1].ulPropTag = PR_EMAIL_ADDRESS; 
props[1].Value.lpszW = recipients[0].sEmail.GetBuffer(0); 
//Set the message status to indicate this message needs 
//enumeration. Vital property! 
props[2].ulPropTag = PR_DISPLAY_NAME; 
props[2].Value.lpszW = recipients[0].sEmail.GetBuffer(0); 

// Finally set the properties on the message 
hr = m_pMessage->SetProps(sizeof(props) / sizeof(props[0]), 
(LPSPropValue)&props, NULL); 

这段 先去掉
------解决方案--------------------
props[1].ulPropTag = PR_EMAIL_ADDRESS; 
属性应该是PR_SENDER_EMALI_ADDRESS

还有就是要增加一个属性

PR_MESSAGE_CLASS,是“IPM.SMStext”
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: