void __stdcall COAddin::OnSend(IDispatch * Item, bool Cancel)
{
MessageBoxA(NULL, "On Send Clicked", "Info", MB_OK);
CComPtr<outlook::_mailitem xmlns:outlook="#unknown"> mail;
HRESULT hr;
if (Item->QueryInterface(IID__MailItem,(void**)&mail) == S_OK)
{
IUnknown* mapiItem;
if (mail->get_MAPIOBJECT(&mapiItem) == S_OK)
{
BSTR subj;
mail->get_Subject(&subj);
MessageBoxW(NULL, (LPCWSTR)subj, L"Subject", MB_OK);
}
}
else
{
MessageBoxA(NULL, "QueryInterface failed", "Info", MB_OK);
return;
}
MessageBoxA(NULL, "On Send Clicked succeeded", "Info", MB_OK);
CComPtr<outlook::attachments> spAttachments;
CComPtr<outlook::attachment> spAttachment;
BSTR bstrPathName;
ATLASSERT(mail);
VARIANT index;
index.iVal = 1; index.vt = VT_I2;
mail->get_Attachments(&spAttachments);
ATLASSERT(spAttachments);
long count;
spAttachments->get_Count(&count);
char buf[10] = {0};
itoa ( count, buf, 10 );
MessageBoxW(NULL, (LPCWSTR)buf, L"count", MB_OK);
if (count > 0)
{
spAttachments->Item(index, &spAttachment);
ATLASSERT(spAttachment);
spAttachment->get_FileName(&bstrPathName);
MessageBoxW(NULL, (LPCWSTR)bstrPathName, L"Info", MB_OK);
spAttachment->get_PathName(&bstrPathName);
MessageBoxW(NULL, (LPCWSTR)bstrPathName, L"Info", MB_OK);
}
}
Now from this code i m getting suject, to, cc, bcc and also the attached file name but i m not getting the attached file path from get_PathName function, its showing blank message box... How to get the attached file path from this.. let me know if there is any other way to get the file path and also how to get the file names and attachments path if there is more than one attachment..Pls help me in this..
Thanks in advance