Example #1
0
        /// <summary>
        /// Gets a list of all recipients.
        /// </summary>
        /// <returns></returns>
        public MailMessageRecipientCollection GetAllRecipients()
        {
            MailMessageRecipientCollection results = new MailMessageRecipientCollection();

            results.AddRange(this.To);
            results.AddRange(this.Cc);
            results.AddRange(this.Bcc);

            // return...
            return(results);
        }
Example #2
0
        /// <summary>
        /// Configures and sends a message via SMTP.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="cc"></param>
        /// <param name="bcc"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="format"></param>
        public static void SendViaSmtp(string from, string toAsString, string ccAsString, string bccAsString, string subject, string body, MailFormat format,
                                       SmtpConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            // add...
            MailMessageRecipientCollection to = new MailMessageRecipientCollection();

            if (toAsString != null && toAsString.Length > 0)
            {
                to.AddRange(toAsString);
            }
            MailMessageRecipientCollection cc = new MailMessageRecipientCollection();

            if (ccAsString != null && ccAsString.Length > 0)
            {
                cc.AddRange(ccAsString);
            }
            MailMessageRecipientCollection bcc = new MailMessageRecipientCollection();

            if (bccAsString != null && bccAsString.Length > 0)
            {
                bcc.AddRange(bccAsString);
            }

            // defer...
            SendViaSmtp(new MailMessageRecipient(from), to, cc, bcc, subject, body, format, settings);
        }
Example #3
0
        /// <summary>
        /// Configures and sends a message via SMTP.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="cc"></param>
        /// <param name="bcc"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="format"></param>
        public static void SendViaSmtp(string from, string toAsString, string ccAsString, string bccAsString, string subject, string body, MailFormat format,
                                       string hostName, string username, string password)
        {
            // add...
            MailMessageRecipientCollection to = new MailMessageRecipientCollection();

            if (toAsString != null && toAsString.Length > 0)
            {
                to.AddRange(toAsString);
            }
            MailMessageRecipientCollection cc = new MailMessageRecipientCollection();

            if (ccAsString != null && ccAsString.Length > 0)
            {
                cc.AddRange(ccAsString);
            }
            MailMessageRecipientCollection bcc = new MailMessageRecipientCollection();

            if (bccAsString != null && bccAsString.Length > 0)
            {
                bcc.AddRange(bccAsString);
            }

            // defer...
            SendViaSmtp(new MailMessageRecipient(from), to, cc, bcc, subject, body, format, hostName, username, password);
        }