当前位置: 首页>>代码示例>>C++>>正文


C++ LPADRBOOK::CreateOneOff方法代码示例

本文整理汇总了C++中LPADRBOOK::CreateOneOff方法的典型用法代码示例。如果您正苦于以下问题:C++ LPADRBOOK::CreateOneOff方法的具体用法?C++ LPADRBOOK::CreateOneOff怎么用?C++ LPADRBOOK::CreateOneOff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPADRBOOK的用法示例。


在下文中一共展示了LPADRBOOK::CreateOneOff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddOneOffAddress

_Check_return_ HRESULT AddOneOffAddress(
	_In_ LPMAPISESSION lpMAPISession,
	_In_ LPMESSAGE lpMessage,
	_In_z_ LPCTSTR szDisplayName,
	_In_z_ LPCTSTR szAddrType,
	_In_z_ LPCTSTR szEmailAddress,
	ULONG ulRecipientType)
{
	HRESULT hRes = S_OK;
	LPADRLIST lpAdrList = NULL; // ModifyRecips takes LPADRLIST
	LPADRBOOK lpAddrBook = NULL;
	LPENTRYID lpEID = NULL;

	enum
	{
		NAME,
		ADDR,
		EMAIL,
		RECIP,
		EID,
		NUM_RECIP_PROPS
	};

	if (!lpMessage || !lpMAPISession) return MAPI_E_INVALID_PARAMETER;

	EC_MAPI(lpMAPISession->OpenAddressBook(
		NULL,
		NULL,
		NULL,
		&lpAddrBook));

	EC_MAPI(HrAllocAdrList(NUM_RECIP_PROPS, &lpAdrList));

	// Setup the One Time recipient by indicating how many recipients
	// and how many properties will be set on each recipient.

	if (SUCCEEDED(hRes) && lpAdrList)
	{
		lpAdrList->cEntries = 1;	// How many recipients.
		lpAdrList->aEntries[0].cValues = NUM_RECIP_PROPS; // How many properties per recipient

		// Set the SPropValue members == the desired values.
		lpAdrList->aEntries[0].rgPropVals[NAME].ulPropTag = PR_DISPLAY_NAME;
		lpAdrList->aEntries[0].rgPropVals[NAME].Value.LPSZ = (LPTSTR)szDisplayName;

		lpAdrList->aEntries[0].rgPropVals[ADDR].ulPropTag = PR_ADDRTYPE;
		lpAdrList->aEntries[0].rgPropVals[ADDR].Value.LPSZ = (LPTSTR)szAddrType;

		lpAdrList->aEntries[0].rgPropVals[EMAIL].ulPropTag = PR_EMAIL_ADDRESS;
		lpAdrList->aEntries[0].rgPropVals[EMAIL].Value.LPSZ = (LPTSTR)szEmailAddress;

		lpAdrList->aEntries[0].rgPropVals[RECIP].ulPropTag = PR_RECIPIENT_TYPE;
		lpAdrList->aEntries[0].rgPropVals[RECIP].Value.l = ulRecipientType;

		lpAdrList->aEntries[0].rgPropVals[EID].ulPropTag = PR_ENTRYID;

		// Create the One-off address and get an EID for it.
		EC_MAPI(lpAddrBook->CreateOneOff(
			lpAdrList->aEntries[0].rgPropVals[NAME].Value.LPSZ,
			lpAdrList->aEntries[0].rgPropVals[ADDR].Value.LPSZ,
			lpAdrList->aEntries[0].rgPropVals[EMAIL].Value.LPSZ,
			fMapiUnicode,
			&lpAdrList->aEntries[0].rgPropVals[EID].Value.bin.cb,
			&lpEID));
		lpAdrList->aEntries[0].rgPropVals[EID].Value.bin.lpb = (LPBYTE)lpEID;

		EC_MAPI(lpAddrBook->ResolveName(
			0L,
			fMapiUnicode,
			NULL,
			lpAdrList));

		// If everything goes right, add the new recipient to the message
		// object passed into us.
		EC_MAPI(lpMessage->ModifyRecipients(MODRECIP_ADD, lpAdrList));

		EC_MAPI(lpMessage->SaveChanges(KEEP_OPEN_READWRITE));
	}

	MAPIFreeBuffer(lpEID);
	if (lpAdrList) FreePadrlist(lpAdrList);
	if (lpAddrBook) lpAddrBook->Release();
	return hRes;
} // AddOneOffAddress
开发者ID:JasonSchlauch,项目名称:mfcmapi,代码行数:84,代码来源:MAPIABFunctions.cpp


注:本文中的LPADRBOOK::CreateOneOff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。