/// <summary>
        /// Send out the email via the smtp server given.  If
        /// the SMTP server throws an error, an SmtpException will
        /// be thrown.  All other exceptions will be MailExceptions
        /// </summary>
        /// <param name="smtpserver">The outgoing SMTP server.</param>
        /// <returns>true if sent successfully.  (note that this
        /// will not currently return false, but in the future
        /// a false value may be used)</returns>
        public bool Send(SmtpServer smtpserver)
        {
            //SmtpProxy smtpproxy=smtpserver.GetSmtpProxy();
            if (_fromaddress == null)
            {
                throw new MailException(ARM.GetInstance().GetString("error_no_from"));
            }

            EmailAddress envelopefrom = _envelopefromaddress;

            if (envelopefrom == null)
            {
                envelopefrom = _fromaddress;
            }
            EmailAddressCollection allrecipients = new EmailAddressCollection();

            allrecipients.AddCollection(_toaddresses);
            allrecipients.AddCollection(_ccaddresses);
            allrecipients.AddCollection(_bccaddresses);
            return(smtpserver.Send(this, allrecipients, envelopefrom));
        }
 private String GetNoMimeMessage()
 {
     return(ARM.GetInstance().GetString("this_is_mime"));
 }
        /// <summary>
        /// Get the minimal header set in the specified character,
        /// and using the mime encoder provided.
        /// </summary>
        private MessageHeaderCollection GetStandardHeaders(System.Text.Encoding charset, IEncoder encoder)
        {
            MessageHeaderCollection standardheaders = new MessageHeaderCollection();

            standardheaders.Add(new MessageHeader("From", _fromaddress.ToDataString()));
            standardheaders.Add(new MessageHeader("To", _toaddresses.ToDataString()));

            if (_ccaddresses.Count > 0)
            {
                standardheaders.Add(new MessageHeader("Cc", _ccaddresses.ToString()));
            }
            //if (_bccaddresses.Count>0)
            //{
            //standardheaders.Add(new MessageHeader("Bcc", _bccaddresses.ToString()));
            //}

            String subject = _subject;

            if (subject == null || subject.Trim() == "")
            {
                subject = EncodeHeaderValue("Subject", ARM.GetInstance().GetString("no_subject"));
            }
            standardheaders.Add(new MessageHeader("Subject", EncodeHeaderValue("Subject", subject)));
            standardheaders.Add(new MessageHeader("Date", new RFC2822Date(DateTime.Now, TimeZone.CurrentTimeZone).ToString()));
            if (!HasBodyTextOnly())
            {
                standardheaders.Add(new MessageHeader("MIME-Version", "1.0"));
            }
            #region X-Mailer Header
            if (_xmailer != null)
            {
                standardheaders.Add(new MessageHeader("X-Mailer", _xmailer));
            }
            else
            {
                String xmailer = Configuration.GetInstance().GetXSender();
                if (xmailer != null)
                {
                    standardheaders.Add(new MessageHeader("X-Mailer", xmailer));
                }
                else
                {
                    standardheaders.Add(new MessageHeader("X-Mailer", "DotNetOpenMail " + VersionInfo.GetInstance().ToString()));
                }
            }
            #endregion

            String contentType = null;
            if (HasBodyTextOnly())
            {
                // ignore the mime stuff for now
            }
            else
            {
                if (HasMixedContent())
                {
                    contentType = "multipart/mixed;" + SmtpProxy.ENDOFLINE +
                                  "        boundary=\"" + _mimeboundary.BoundaryString + "\"";
                }
                else if (HasRelatedContent())
                {
                    contentType = "multipart/related;" + SmtpProxy.ENDOFLINE +
                                  "        boundary=\"" + _mimeboundary.BoundaryString + "\"";
                }
                else
                {
                    contentType = "multipart/alternative;" + SmtpProxy.ENDOFLINE +
                                  "        boundary=\"" + _mimeboundary.BoundaryString + "\"";
                }

                // note: see http://www.faqs.org/rfcs/rfc2045.html , part 6.4
                //contentType+="        charset=\""+charset.BodyName+"\"";

                standardheaders.Add(new MessageHeader("Content-Type", contentType));
                //standardheaders.Add(new MessageHeader("Content-Transfer-Encoding", encoder.ContentTransferEncodingString));
            }
            return(standardheaders);
        }