36#include "wx/wfstream.h"
48 const wxString& profileName,
const wxString& sendMail2,
49 const wxString& sendMail1,
const wxString& sendMail0) {
50 wxString mailURL = _T(
"mailto:");
52 message.m_to[0] + _T(
"?&subject=") + message.m_subject + _T(
"&body=");
53 wxString msgBody = message.m_body;
54 msgBody.Replace(
" ",
"%20");
55 msgBody.Replace(
"\n",
"%0A");
58 wxLaunchDefaultBrowser(mailURL);
62 wxASSERT (!message.m_to.IsEmpty()) ;
63 wxString profile(profileName);
64 if (profile.IsEmpty())
65 profile = wxGetUserName();
69 if (!session.MapiInstalled())
71 if (!session.Logon(profile))
74 return session.Send(message);
77#elif defined(__UNIX__)
79 const wxString& profileName,
const wxString& sendMail2,
80 const wxString& sendMail1,
const wxString& sendMail0) {
81 wxASSERT_MSG(!message.m_to.IsEmpty(), _T(
"no recipients to send mail to"));
83 wxString from = message.m_from;
85 from = wxGetEmailAddress();
88 wxString msg, sendmail;
90 if (sendMethod == 0) {
93 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) {
94 if (rcpt > 0) addr <<
",";
95 addr << message.m_to[rcpt];
97 wxString msg = wxString::Format(
98 "sh -c \"open 'mailto:%s?subject=%s&body=%s'\"", addr.c_str(),
99 message.m_subject.c_str(), message.m_body.c_str());
100 long ret = wxExecute(msg.c_str());
103 if (wxFileExists(sendMail0))
104 sendmail << sendMail0;
105 else if (wxFileExists(sendMail1))
106 sendmail << sendMail1;
109 _T(
"MAIL Error: xdg-email is not installed on this computer!"));
113 msg <<
"sh -c \" " << sendmail <<
" --utf8 --subject '"
114 << message.m_subject <<
"' "
115 <<
"--body '" << message.m_body <<
"'";
116 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++)
117 msg <<
" '" << message.m_to[rcpt] <<
"'";
120 wxSystem(msg.c_str());
125 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) {
126 if (rcpt) msg << wxT(
", ");
127 msg << message.m_to[rcpt];
129 msg << wxT(
"\nFrom: ") << from << wxT(
"\nSubject: ") << message.m_subject;
130 msg << wxT(
"\n\n") << message.m_body;
133 filename.Printf(wxT(
"/tmp/msg-%ld-%ld-%ld.txt"), (
long)getpid(),
134 wxGetLocalTime(), (
long)rand());
136 wxFileOutputStream stream(filename);
138 stream.Write(msg.ToUTF8(), msg.Length());
143 sendmail << sendMail2;
146 cmd << sendmail << wxT(
" < ") << filename;
149 wxSystem(cmd.c_str());
151 wxRemoveFile(filename);
159wxLogMessage(_T(
"Send eMail not yet implemented for this platform"));
Email Request System for GRIB Data.