38#include "wx/wfstream.h"
50 const wxString& profileName,
const wxString& sendMail2,
51 const wxString& sendMail1,
const wxString& sendMail0) {
52 wxString mailURL =
"mailto:";
53 mailURL += message.m_to[0] +
"?&subject=" + message.m_subject +
"&body=";
54 wxString msgBody = message.m_body;
55 msgBody.Replace(
" ",
"%20");
56 msgBody.Replace(
"\n",
"%0A");
59 wxLaunchDefaultBrowser(mailURL);
63 wxASSERT (!message.m_to.IsEmpty()) ;
64 wxString profile(profileName);
65 if (profile.IsEmpty())
66 profile = wxGetUserName();
70 if (!session.MapiInstalled())
72 if (!session.Logon(profile))
75 return session.Send(message);
78#elif defined(__UNIX__)
80 const wxString& profileName,
const wxString& sendMail2,
81 const wxString& sendMail1,
const wxString& sendMail0) {
82 wxASSERT_MSG(!message.m_to.IsEmpty(),
"no recipients to send mail to");
84 wxString from = message.m_from;
86 from = wxGetEmailAddress();
89 wxString msg, sendmail;
91 if (sendMethod == 0) {
94 for (
size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) {
95 if (rcpt > 0) addr <<
",";
96 addr << message.m_to[rcpt];
98 wxString msg = wxString::Format(
99 "sh -c \"open 'mailto:%s?subject=%s&body=%s'\"", addr.c_str(),
100 message.m_subject.c_str(), message.m_body.c_str());
101 long ret = wxExecute(msg.c_str());
104 if (wxFileExists(sendMail0))
105 sendmail << sendMail0;
106 else if (wxFileExists(sendMail1))
107 sendmail << sendMail1;
109 wxLogMessage(
"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 <<
", ";
127 msg << message.m_to[rcpt];
129 msg <<
"\nFrom: " << from <<
"\nSubject: " << message.m_subject;
130 msg <<
"\n\n" << message.m_body;
133 filename.Printf(
"/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 <<
" < " << filename;
149 wxSystem(cmd.c_str());
151 wxRemoveFile(filename);
159wxLogMessage(
"Send eMail not yet implemented for this platform");
Email Request System for GRIB Data.