1
This question은 비슷하지만받는 사람을 추가하는 방법을 보여주지 않습니다.C++에서 MAPI를 사용하여 프로그래밍 방식으로 알려진 첨부 파일이있는 전자 메일을 보내는 방법은 무엇입니까? MAPISendMail()
어떻게 둘 다합니까?
우리는 2008
은 기본적으로 우리가 이메일을 보낼
우리는 비주얼 스튜디오를 사용하고 가능한 한 많은 Windows 플랫폼 가능 (XP에서 이상) 넓은 지원을하고 싶습니다 :
를- 프리 필드 대상 주소
- 첨부 파일
- 제목
우리 프로그램에서 제공 한 정보를 추가하거나 취소 할 수있는 권한을 사용자에게 부여합니다.
편집 내가 MAPISendMail()를 내가 상단에 링크 된 질문에서 코드의 많은 부분을 복사,하지만 난 어떤 이메일 DLG 상자와 내가 전화에서 얻을 오류 수익을 얻을 사용하려고은 다음과 같습니다 0x000f - "
:이 시스템은나는 수신자를 설정하기 위해 줄을 주석 경우
, 그것은 여기 코드입니다 (I 더받는 사람에 미리 채워지지 않은 다음의 과정) 잘 작동 "지정된 드라이브를 찾을 수 없습니다#include <tchar.h>
#include <windows.h>
#include <mapi.h>
#include <mapix.h>
int _tmain(int argc, wchar_t *argv[])
{
HMODULE hMapiModule = LoadLibrary(_T("mapi32.dll"));
if (hMapiModule != NULL)
{
LPMAPIINITIALIZE lpfnMAPIInitialize = NULL;
LPMAPIUNINITIALIZE lpfnMAPIUninitialize = NULL;
LPMAPILOGONEX lpfnMAPILogonEx = NULL;
LPMAPISENDDOCUMENTS lpfnMAPISendDocuments = NULL;
LPMAPISESSION lplhSession = NULL;
LPMAPISENDMAIL lpfnMAPISendMail = NULL;
lpfnMAPIInitialize = (LPMAPIINITIALIZE)GetProcAddress(hMapiModule, "MAPIInitialize");
lpfnMAPIUninitialize = (LPMAPIUNINITIALIZE)GetProcAddress(hMapiModule, "MAPIUninitialize");
lpfnMAPILogonEx = (LPMAPILOGONEX)GetProcAddress(hMapiModule, "MAPILogonEx");
lpfnMAPISendDocuments = (LPMAPISENDDOCUMENTS)GetProcAddress(hMapiModule, "MAPISendDocuments");
lpfnMAPISendMail = (LPMAPISENDMAIL)GetProcAddress(hMapiModule, "MAPISendMail");
if (lpfnMAPIInitialize && lpfnMAPIUninitialize && lpfnMAPILogonEx && lpfnMAPISendDocuments)
{
HRESULT hr = (*lpfnMAPIInitialize)(NULL);
if (SUCCEEDED(hr))
{
hr = (*lpfnMAPILogonEx)(0, NULL, NULL, MAPI_EXTENDED | MAPI_USE_DEFAULT, &lplhSession);
if (SUCCEEDED(hr))
{
// this opens the email client
// create the msg. We need to add recipients AND subject AND the dmp file
// file attachment
MapiFileDesc filedesc;
::ZeroMemory(&filedesc, sizeof(filedesc));
filedesc.nPosition = (ULONG)-1;
filedesc.lpszPathName = "E:\\Development\\Open\\testmail\\testmail.cpp";
// recipient(s)
MapiRecipDesc recip;
::ZeroMemory(&recip, sizeof(recip));
recip.lpszName = "QA email";
recip.lpszAddress = "[email protected]";
// the message
MapiMessage msg;
::ZeroMemory(&msg, sizeof(msg));
msg.lpszSubject = "Test";
msg.nRecipCount = 1; // if I comment out this line it works fine...
msg.lpRecips = &recip;
msg.nFileCount = 1;
msg.lpFiles = &filedesc;
hr = (*lpfnMAPISendMail)(0, NULL, &msg, MAPI_LOGON_UI|MAPI_DIALOG, 0);
if (SUCCEEDED(hr))
{
hr = lplhSession->Logoff(0, 0, 0);
hr = lplhSession->Release();
lplhSession = NULL;
}
}
}
(*lpfnMAPIUninitialize)();
}
FreeLibrary(hMapiModule);
}
return 0;
}
로그온 및 초기화 작업이 필요 없다고 생각합니다. (* lpfnMAPISendMail)()는 독립형으로 작동합니다. – thomiel