Пример #1
0
        public bool SendMail(string strSender, string strReceiver, string strCC, string strBcc, AttachFile[] AttachFiles, string strSubject, string strContent, bool bIsHtml, string strCreateBy, string strSysID)
        {
            Common.Util.MessageUtil message = new Common.Util.MessageUtil("smtp.163.com", "*****@*****.**", "justinle", "justinle", "052924e*fa!");
            EMailContent content = new Common.Util.EMailContent();
            content.Subject = "test";
            content.ToAddress = strReceiver.Split(';').ToList();
            content.Content = "test aaa";

            message.Send(content);
            return true;
        }
Пример #2
0
        /// <summary>
        /// 通過SmtpClient發送帶有附件的郵件
        /// </summary>
        /// <param name="email"></param>
        /// <param name="attachmentPath"></param>
        public void Send(EMailContent email, string attachmentPath)
        {
            Attachment add = new Attachment(attachmentPath);
            SmtpClient smtp = new SmtpClient(m_EMailHost);

            MailMessage mail = new MailMessage();
            for (int i = 0; i < email.ToAddress.Count; i++)
            {
                mail.To.Add(email.ToAddress[i]);
            }
            mail.Subject = email.Subject;
            for (int i = 0; i < email.CCList.Count; i++)
            {
                mail.CC.Add(email.CCList[i]);
            }
            mail.Body = email.Content;
            MailAddress from = new MailAddress(m_FromAddress);
            mail.From = from;
            mail.Attachments.Add(add);
            smtp.Credentials = new NetworkCredential(m_FromUserName, m_FromPassword);
            smtp.Send(mail);
        }