BEGIN_MESSAGE_MAP(CPrevPrintView, CScrollView)
//{{AFX_MSG_MAP(CPrevPrintView)
...............................................
ON_BN_CLICKED(ID_PREVIEW_MAIL, OnPreviewMail)
...............................................
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CPrevPrintView::OnPreviewMail() {
TCHAR PathName[_MAX_PATH] = "MyPath", EmailAddr[_MAX_PATH] = "MyAddress", Subject[_MAX_PATH] = "MySubject";
//Load MAPI32.DLL, get MAPISendMail addresses.
if (!m_SimpleMAPI.InitSimpleMAPI())
return;
MapiMessage msgSend;
memset(&msgSend, 0, sizeof(MapiMessage));
MapiFileDesc fileDesc;
memset(&fileDesc, 0, sizeof(MapiFileDesc));
MapiRecipDesc recipDesc;
memset(&recipDesc, 0, sizeof(MapiRecipDesc));
msgSend.flFlags = MAPI_SENT;//The message is to be sent.
msgSend.lpszSubject = Subject;//The message is "דוח מיכפל".
fileDesc.lpszPathName = PathName;//Fill lpszPathName with report file name.
fileDesc.nPosition = -1;
// Attach report file.
msgSend.nFileCount = 1;
msgSend.lpFiles = &fileDesc;
recipDesc.lpszName = EmailAddr; // Fill lpszName with E-mail address.
recipDesc.ulRecipClass = MAPI_TO; //Indicates a primary message recipient.
// Set mail recipient.
msgSend.nRecipCount = 1;
msgSend.lpRecips = &recipDesc;
// Send mail.
BOOL bMailerExist = TRUE;
ULONG ulResult = m_SimpleMAPI.MAPISendMail(0, 0, &msgSend, MAPI_DIALOG | MAPI_LOGON_UI, 0L);
m_SimpleMAPI.DeinitSimpleMAPI();
}
BOOL CSimpleMAPI::InitSimpleMAPI()
{
m_hlibMAPI = LoadLibrary(szMAPIDLL);
if (m_hlibMAPI) {
m_pfnMAPILogon = (LPMAPILOGON)GetProcAddress(m_hlibMAPI, "MAPILogon");
m_pfnMAPISendMail = (LPMAPISENDMAIL)GetProcAddress(m_hlibMAPI, "MAPISendMail");
m_pfnMAPILogoff = (LPMAPILOGOFF)GetProcAddress(m_hlibMAPI, "MAPILogoff");
if (m_pfnMAPILogon && m_pfnMAPISendMail && m_pfnMAPILogoff)
return TRUE;
........................................
}
else {
........................................
}
............................................
return FALSE;
}
// DeinitSimpleMAPI unloads MAPI32.DLL.
void CSimpleMAPI::DeinitSimpleMAPI()
{
if (m_hlibMAPI) {
FreeLibrary (m_hlibMAPI);
m_hlibMAPI = NULL;
}
}
It worked well but now we encountered with error 26 (command not supported). This happens
in hebrew Windows 10 64-bit OS with Microsoft Outlook 2010 or Outlook 2016 installed after upgrade from Windows Version 1.7.0.3 to Version 1.7.0.9. We have now 8 users complained. We advised to these users return to Version 1.7.0.3 and the problem has disappeared.