Exemplo n.º 1
0
        /// <summary>
        /// send all records at once
        /// </summary>
        /// <param name="data">what to send</param>
        /// <param name="destination">what email address to send to</param>
        /// <returns>the number of records sent is returened, ie the row shape of the data</returns>
        public int SendAllRecords(DataRecordCollection data, string destination)
        {
            var    fromAddress = new MailAddress(email_from, email_from.Split('@')[0]);
            var    toAddress   = new MailAddress(destination, destination.Split('@')[0]);
            string email_body  = this.body + "\n" + data.ToString();



            var smtp = new SmtpClient
            {
                Host                  = server,
                Port                  = Port,
                EnableSsl             = ssl,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, password)
            };

            using (var msg = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject_line,
                Body = email_body
            })
            {
                smtp.Send(msg);
            }

            return(data.GetShape().Rows);
        }
Exemplo n.º 2
0
        public int SendAllRecords(DataRecordCollection data, string destination)
        {
            string sending_body = email_body;

            sending_body += Environment.NewLine;
            sending_body += data.ToString();
            SendMailItem(destination, sending_body);
            return(data.GetShape().Rows);
        }