本文整理汇总了C++中std::tstring::find方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::find方法的具体用法?C++ tstring::find怎么用?C++ tstring::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tstring
的用法示例。
在下文中一共展示了tstring::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindLinkedEmail
IDispatchPtr FindLinkedEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, Workshare::Mail::Mapi::MapiSession& session, const std::tstring& sMessageId)
{
if(spDispOutlook == 0)
throw Workshare::ArgumentNullException(_T("spDispOutlook"), _T("Outlook Application pointer is null."));
if(spDispNameSpace == 0)
throw Workshare::ArgumentNullException(_T("spDispNameSpace"), _T("MAPI NameSpace pointer is null."));
if(sMessageId.empty())
throw Workshare::ArgumentException(_T("sMessageId"), _T("The message ID of the email to find was not specified."));
size_t pos = sMessageId.find(_T(';'));
if(-1 == pos)
throw Workshare::ArgumentException(_T("sMessageId"), _T("Invalid message ID (should be in format EntryId;SearchKey[;InternetId])"));
std::tstring sEntryId = sMessageId.substr(0, pos);
std::tstring sSearchKeyAndInternetId = sMessageId.substr(pos + 1);
std::tstring sSearchKey;
std::tstring sInternetId;
pos = sSearchKeyAndInternetId.find(_T(';'));
if(-1 != pos)
{
sSearchKey = sSearchKeyAndInternetId.substr(0, pos);
sInternetId = sSearchKeyAndInternetId.substr(pos + 1);
}
else
sSearchKey = sSearchKeyAndInternetId;
Outlook::_ApplicationPtr spOutlook = spDispOutlook;
Outlook::_NameSpacePtr spNameSpace = spDispNameSpace;
IDispatchPtr spLinkedEmail;
HRESULT hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtMissing, &spLinkedEmail);
if(FAILED(hr))
{
std::tstring sStoreId;
Workshare::Mail::Mapi::FindItemBySearchKey(session, sSearchKey, sEntryId, sStoreId);
_variant_t vtStoreId(sStoreId.c_str());
hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtStoreId, &spLinkedEmail);
if(FAILED(hr))
throw Workshare::Com::ComException(_T("Outlook failed to open email"), hr, spNameSpace);
//If this fails we could create a function FindItemByInternetId(session, sInternetId, sEntryId, sStoreId);
}
return spLinkedEmail;
}