From 8e2ff10c71fc0a4cbb91bf872fe894b934f7a2e7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Sep 2005 00:15:32 +0000 Subject: [PATCH] fixed bug in generation of the To: header: trailing comma prevented the messages from being ever sent out git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35426 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/net/email.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/contrib/src/net/email.cpp b/contrib/src/net/email.cpp index 2d4c857115..77a6aabcd0 100644 --- a/contrib/src/net/email.cpp +++ b/contrib/src/net/email.cpp @@ -61,29 +61,31 @@ bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, const wx return session.Send(message); } #elif defined(__UNIX__) -bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, const wxString& sendMail) +bool +wxEmail::Send(wxMailMessage& message, + const wxString& profileName, + const wxString& sendMail) { - wxASSERT (message.m_to.GetCount() > 0) ; + wxASSERT_MSG( !message.m_to.IsEmpty(), _T("no recipients to send mail to") ) ; + // The 'from' field is optionally supplied by the app; it's not needed // by MAPI, and on Unix, will be guessed if not supplied. wxString from = message.m_from; - if (from.IsEmpty()) + if ( from.empty() ) { from = wxGetEmailAddress(); } - wxASSERT (!from.IsEmpty()); - wxString msg; msg << wxT("To: "); - size_t i; - for (i = 0; i < message.m_to.GetCount(); i++) + const size_t rcptCount = message.m_to.GetCount(); + for (size_t rcpt = 0; rcpt < rcptCount; rcpt++) { - msg << message.m_to[i]; - if (i < message.m_to.GetCount()) + if ( rcpt ) msg << wxT(", "); + msg << message.m_to[rcpt]; } msg << wxT("\nFrom: ") << from << wxT("\nSubject: ") << message.m_subject;