Пример #1
0
 /// <summary>
 /// 设置邮件发信人信息
 /// </summary>
 /// <param name="from">发信人地址</param>
 /// <param name="displayName">发信人显示名</param>
 public void SetFrom(string from, string displayName = null)
 {
     if (!MailAudit.ValidateRecipients(from))
     {
         throw new ArgumentException("The mail's from is invalid.");
     }
     this.mailMessage.From = new MailAddress(from, displayName);
 }
Пример #2
0
        /// <summary>
        /// 添加收件人。
        /// 若收件人不符合 mail 格式,将会被移除
        /// </summary>
        /// <param name="to">要添加的收件人</param>
        public void AddTo(string to)
        {
            if (!MailAudit.ValidateRecipients(to))
            {
                return;
            }

            this.mailMessage.To.Add(new MailAddress(to));
        }
Пример #3
0
        /// <summary>
        /// 添加密送人。
        /// 若密送不符合 mail 格式,将会被移除
        /// </summary>
        /// <param name="bcc">要添加的密送人</param>
        public void AddBcc(string bcc)
        {
            if (!MailAudit.ValidateRecipients(bcc))
            {
                return;
            }

            this.mailMessage.Bcc.Add(new MailAddress(bcc));
        }
Пример #4
0
        /// <summary>
        /// 添加附件。
        /// 若附件路径不合法,将会被移除
        /// </summary>
        /// <param name="attachment">要添加的附件的绝对路径</param>
        public void AddAttachment(string attachment)
        {
            if (!MailAudit.ValidateAttachment(attachment))
            {
                return;
            }

            this.mailMessage.Attachments.Add(new Attachment(attachment, MediaTypeNames.Application.Octet));
        }
Пример #5
0
        /// <summary>
        /// 添加抄送人。
        /// 若抄送人不符合 mail 格式,将会被移除
        /// </summary>
        /// <param name="cc">要添加的抄送人</param>
        public void AddCc(string cc)
        {
            if (!MailAudit.ValidateRecipients(cc))
            {
                return;
            }

            this.mailMessage.CC.Add(new MailAddress(cc));
        }