Originally posted by: mike
As for someone's question about it failing if Outlook is not running, just add this code before you do the send:
For the life of me, I could not find out why it was failing. Then I found out that if you pass the CC a blank string, it will fail.
// first, determine if Outlook is running
HANDLE outlook;
outlook = FindWindowEx(NULL, NULL, "rctrl_renwnd32", NULL);
if (outlook == NULL)
{
// need to launch outlook
ShellExecute(NULL, "open", "outlook", "", "", SW_SHOWNORMAL );
// wait for a second
Sleep(1000);
// continue
}
Originally posted by: Matt Frear
Since I upgraded to SR1, when you try and send using IMAP the user is presented with a dialog box:
"A program is trying to send email on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose 'No'."
At which point the user is supposed to hit Yes. A hack would be to intercept the dialog and hit Yes myself, but this is rather unprofessional.
I hope there's a switch somewhere in Outlooks options to address this. Anyone found it?
ReplyOriginally posted by: Trond Thorjussen
Thank you very much. Just what I have been looking for, a long time.
I owe you a beer! Give me a hint next time you are in Horten, Norway.
Originally posted by: Saar
Any Ideas why this sample doesn't work if the outlook is ot running ?
if so could you plaese e-mail me the answer.
Thanks
Originally posted by: Simon Pogrebinsky
How to display composed email message without sending it out? Thank you.
ReplyOriginally posted by: Pail
ie:
// Save the message
Regards.
Have you worked out a MailSave funtion that works. Need to save a message received by my own transport.
void CPGPSDoc::SaveMail()
{
HRESULT hRes = S_OK;
FLAGS flFlags = NULL;
lpMapiMessage *lppMessage = NULL;
LPTSTR *lppszMessageID = NULL;
MapiMessage Message;
char lpszMessageID[MAX_MSGID] = {NULL};
MapiRecipDesc rdOriginator = {0L, MAPI_ORIG, (LPSTR)"Paul Prokopuik",
(LPSTR)"ppro@datatrac.ca"};
MapiRecipDesc rdRecips = {0L, MAPI_TO, (LPSTR)"Paul Prokopuik",
(LPSTR)"ppro@datatrac.ca"}; // Always make sure there is a valid session
if ( g_hSession )
{
// Clear out memory for Message.
ZeroMemory ( &Message, sizeof ( MapiMessage ) );
Message.ulReserved = 0L;
Message.lpszNoteText = "Any note text 2";
Message.lpszMessageType = NULL;
Message.lpszSubject = "A new message from Swap.exe";
Message.lpRecips = &rdRecips
Message.lpOriginator = &rdOriginator
Message.nFileCount = 0L;
Message.nRecipCount = 0L;
Message.lpFiles = NULL;
Message.flFlags = MAPI_SENT;
hRes = (*g_lpfnSaveMail) ( g_hSession,
(ULONG)this,
&Message,
NULL,
0L,
lpszMessageID );
...
none of the above stores Recipient TO:
Originally posted by: Perry
This class really helped me out a lot. Thank you!
ReplyOriginally posted by: Jim Chapman
How can i set the format for the message body as html?
thanks
jim
Originally posted by: Igor Proskuriakov
Hi,
It seems that call to MAPISendMail changes current directory to c:\winnt\system32. Can anybody confirm it? Is it a bug or a feature?
Regards,
Igor
Originally posted by: Bernd van Lier
Add this line in IMapi.h (private section):
(FARPROC&) m_lpfnLogon = GetProcAddress(m_hInstMail, "MAPILogon");
if (m_lpfnLogon == NULL)
ASSERT(m_lpfnLogon != NULL);
In Function
and create a new public function called
BOOL CIMapi::Logon(char * profileName, char * Password)
LHANDLE hSession;
int nError = m_lpfnLogon(
if (nError != SUCCESS_SUCCESS )
return TRUE;
Call this function before calling the Send() function.
For auto logon and profile selection (without bringing up a dialog) add these lines below.
ULONG (PASCAL *m_lpfnLogon)(ULONG, LPTSTR, LPTSTR, FLAGS, ULONG, LPLHANDLE);
Add these lines in CIMapi::CIMapi() behind MAPISendMail
{
AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
m_error = IMAPI_INVALIDDLL;
return;
}
replace this line
int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0);
with this
int nError = m_lpfnSendMail(0, 0, &m_message, flags, 0);
{
CWaitCursor wait;
NULL,
profileName,
Password,
0,
0,
&hSession);
m_error = nError;
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
return FALSE;
}
}
Parameters:
profileName - a valid profile like "Microsoft Outlook"
Password - your password (not always required)