Import the complete path of the following files in your application using the #import statement:
- MSO9.DLL
- msoutl9.olb
HRESULT hr;CComBSTR inputStr;inputStr = CString("MAPI").GetBuffer(0);CoInitialize(NULL);Outlook::_ApplicationPtr xyz("Outlook.Application");_bstr_t name(inputStr, true);Outlook::_NameSpacePtr nsp = xyz->GetNamespace(name);CComBSTR cTo = CString("[email protected]").GetBuffer(0);CComBSTR cCC = CString("[email protected]").GetBuffer(0);CComBSTR cBody = CString("this is a test mail").GetBuffer(0);CComBSTR cSub = CString("this is a test mail").GetBuffer(0);_bstr_t to(cTo, true);_bstr_t cc(cCC, true);_bstr_t body(cBody, true);_bstr_t sub(cSub, true);Outlook::_MailItemPtr miPtr = xyz->CreateItem(Outlook::olMailItem);miPtr->put_To(to);miPtr->put_CC(cc);miPtr->put_Body(body);miPtr->put_Subject(sub);hr = miPtr->Send();