36#include "wx/wfstream.h"
48 const wxString& profileName,
const wxString& sendMail2,
49 const wxString& sendMail1,
const wxString& sendMail0) {
50 wxString mailURL =
"mailto:";
51 mailURL += message.m_to[0] +
"?&subject=" + message.m_subject +
"&body=";
52 wxString msgBody = message.m_body;
53 msgBody.Replace(
" ",
"%20");
54 msgBody.Replace(
"\n",
"%0A");
57 wxLaunchDefaultBrowser(mailURL);
61 wxASSERT (!message.m_to.IsEmpty()) ;
62 wxString profile(profileName);
63 if (profile.IsEmpty())
64 profile = wxGetUserName();
68 if (!session.MapiInstalled())
70 if (!session.Logon(profile))
73 return session.Send(message);
76#elif defined(__UNIX__)
78 const wxString& profileName,
const wxString& sendMail2,
79 const wxString& sendMail1,
const wxString& sendMail0) {
80 wxASSERT_MSG(!message.m_to.IsEmpty(),
"no recipients to send mail to");
82 wxString from = message.m_from;
84 from = wxGetEmailAddress();
87 wxString msg, sendmail;
89 if (sendMethod == 0) {
92 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) {
93 if (rcpt > 0) addr <<
",";
94 addr << message.m_to[rcpt];
96 wxString msg = wxString::Format(
97 "sh -c \"open 'mailto:%s?subject=%s&body=%s'\"", addr.c_str(),
98 message.m_subject.c_str(), message.m_body.c_str());
99 long ret = wxExecute(msg.c_str());
102 if (wxFileExists(sendMail0))
103 sendmail << sendMail0;
104 else if (wxFileExists(sendMail1))
105 sendmail << sendMail1;
107 wxLogMessage(
"MAIL Error: xdg-email is not installed on this computer!");
111 msg <<
"sh -c \" " << sendmail <<
" --utf8 --subject '"
112 << message.m_subject <<
"' "
113 <<
"--body '" << message.m_body <<
"'";
114 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++)
115 msg <<
" '" << message.m_to[rcpt] <<
"'";
118 wxSystem(msg.c_str());
123 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) {
124 if (rcpt) msg <<
", ";
125 msg << message.m_to[rcpt];
127 msg <<
"\nFrom: " << from <<
"\nSubject: " << message.m_subject;
128 msg <<
"\n\n" << message.m_body;
131 filename.Printf(
"/tmp/msg-%ld-%ld-%ld.txt", (
long)getpid(),
132 wxGetLocalTime(), (
long)rand());
134 wxFileOutputStream stream(filename);
136 stream.Write(msg.ToUTF8(), msg.Length());
141 sendmail << sendMail2;
144 cmd << sendmail <<
" < " << filename;
147 wxSystem(cmd.c_str());
149 wxRemoveFile(filename);
157wxLogMessage(
"Send eMail not yet implemented for this platform");
Email Request System for GRIB Data.