campo-sirio/xvaga/xvtmail.cpp
guy 3015907da9 Patch level :
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione finestre di richiesta


git-svn-id: svn://10.65.10.50/branches/R_10_00@22475 c028cbd2-c16b-5b4b-a496-9718f37d4682
2011-11-04 15:36:22 +00:00

66 lines
1.5 KiB
C++
Executable File

#include "wxinc.h"
#include "xvt.h"
#include "email.h"
#include <wx/tokenzr.h>
BOOLEAN xvt_mail_installed()
{
BOOLEAN bMapiInstalled = TRUE;
#ifdef __WXMSW__
bMapiInstalled = (::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0) &&
(SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0);
#endif
return bMapiInstalled;
}
BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg,
const char* attach, short flags)
{
bool ui = (flags & 0x1) != 0;
wxStringTokenizer tokTo(to, _T(";"));
wxMailMessage Msg(subject, tokTo.GetNextToken(), msg);
if (flags & 0x2)
Msg.m_query_receipt = true;
while (tokTo.HasMoreTokens())
Msg.AddTo(tokTo.GetNextToken());
if (Msg.m_to[0].IsEmpty())
{
Msg.m_to[0] = " "; // Il destinatario "" fa piantare MAPI con errore 25
ui = true; // Forza user interface in assenza di recipient
}
if (attach && *attach)
{
wxStringTokenizer tokAttach(attach, _T(";"));
while (tokAttach.HasMoreTokens())
Msg.AddAttachment(tokAttach.GetNextToken());
}
if (cc && *cc)
{
wxStringTokenizer Tok(cc, _T(";"));
while (Tok.HasMoreTokens())
Msg.AddCc(Tok.GetNextToken());
}
if (ccn && *ccn)
{
wxStringTokenizer Tok(ccn, _T(";"));
while (Tok.HasMoreTokens())
Msg.AddBcc(Tok.GetNextToken());
}
xvt_fsys_save_dir();
wxEmail Mail;
BOOLEAN ok = Mail.Send(Msg, wxEmptyString, ui);
xvt_fsys_restore_dir();
return ok;
}