コード例 #1
0
        //--- Methods ---
        public void SendNoticeToAdmin(string subject, string content, MimeType mime)
        {
            // TODO (arnec): should this be using the email service?
            UserBE adminUser = UserBL.GetAdmin();

            if (adminUser == null)
            {
                throw new SiteNoAdminFatalException();
            }
            string smtphost = string.Empty;
            int    smtpport = 0;

            if (smtphost == string.Empty)
            {
                throw new SiteConflictException(DekiResources.SMTP_SERVER_NOT_CONFIGURED());
            }
            if (string.IsNullOrEmpty(adminUser.Email))
            {
                throw new SiteConflictException(DekiResources.ADMIN_EMAIL_NOT_SET());
            }
            var smtpclient = new SmtpClient();
            var msg        = new MailMessage();

            msg.To.Add(adminUser.Email);
            msg.From        = new MailAddress(_user.Email, _user.Name);
            msg.Subject     = _dekiInstance.SiteName + ": " + subject;
            msg.Body        = content;
            smtpclient.Host = smtphost;
            if (smtpport != 0)
            {
                smtpclient.Port = smtpport;
            }
            smtpclient.Send(msg);
        }