예제 #1
0
        public static bool SendOK(string MailTo, string MailSubject, string MailBody, bool IsHtml, string MailFrom, string MailFromName, string MailPwd, string MailSmtpHost, int MailSmtpPort)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.MaxRecipientNum = 80;
            mailMessage.From            = ConfigurationManager.AppSettings["Lottery:WebmasterEmail"];
            mailMessage.FromName        = MailFromName;
            string str = MailTo;

            char[] chArray = new char[1] {
                ','
            };
            foreach (string recipient in str.Split(chArray))
            {
                mailMessage.AddRecipients(recipient);
            }
            mailMessage.Subject    = MailSubject;
            mailMessage.BodyFormat = !IsHtml ? MailFormat.Text : MailFormat.HTML;
            mailMessage.Priority   = MailPriority.Normal;
            mailMessage.Body       = MailBody;
            SmtpClient smtpClient = new SmtpClient(MailSmtpHost, MailSmtpPort);

            if (smtpClient.Send(mailMessage, MailFrom, MailPwd))
            {
                return(true);
            }
            MailHelp.SaveErrLog(MailTo, MailFrom, MailFromName, MailSmtpHost, smtpClient.ErrMsg);
            return(false);
        }
예제 #2
0
        public static bool SendOK(string MailTo, string MailSubject, string MailBody, bool IsHtml, string MailFrom, string MailFromName, string MailPwd, string MailSmtpHost, int MailSmtpPort)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.MaxRecipientNum = 80;
            mailMessage.From            = ConfigurationManager.AppSettings["Lottery:WebmasterEmail"];
            mailMessage.FromName        = MailFromName;
            string[] array = MailTo.Split(new char[]
            {
                ','
            });
            for (int i = 0; i < array.Length; i++)
            {
                mailMessage.AddRecipients(array[i]);
            }
            mailMessage.Subject = MailSubject;
            if (IsHtml)
            {
                mailMessage.BodyFormat = MailFormat.HTML;
            }
            else
            {
                mailMessage.BodyFormat = MailFormat.Text;
            }
            mailMessage.Priority = MailPriority.Normal;
            mailMessage.Body     = MailBody;
            SmtpClient smtpClient = new SmtpClient(MailSmtpHost, MailSmtpPort);

            if (smtpClient.Send(mailMessage, MailFrom, MailPwd))
            {
                return(true);
            }
            MailHelp.SaveErrLog(MailTo, MailFrom, MailFromName, MailSmtpHost, smtpClient.ErrMsg);
            return(false);
        }
        public string Post()
        {
            var dateStr = DateTime.UtcNow.ToString("yyyy.MM.dd HH.mm.ss");
            var status  = _defaultStatus;
            var result  = "Build occurred on AppHarbor.\r\n";


            if (Request.Content != null)
            {
                var buffer  = Request.Content.ReadAsByteArrayAsync().Result;
                var postStr = Encoding.UTF8.GetString(buffer);
                if (postStr != null)
                {
                    try
                    {
                        dynamic buildInfo = JObject.Parse(postStr);
                        result += string.Format(_bodyFormat,
                                                buildInfo.application.name,
                                                buildInfo.application.url,
                                                buildInfo.build.commit.message,
                                                buildInfo.build.commit.id,
                                                buildInfo.build.status,
                                                buildInfo.build.url
                                                );

                        status = buildInfo.build.status;
                    }
                    catch (Exception ex)
                    {
                        result += "ERROR: Can not parse payload.\r\n" + ex.Message + "\r\n";
                    }
                }
            }
            else
            {
                result += "ERROR: No payload sent.\r\n";
            }

            result += "Triggered from: " + (Request.GetClientIpAddress() ?? "unknown");

            var mail = new MailMessage();

            mail.Subject = string.Format(_subjectFormat, "Build", status, dateStr);
            mail.AddRecipients(ConfigurationManager.AppSettings["Receivers"]);
            mail.Body = result;

            try
            {
                new SmtpClient().Send(mail);
            }
            catch (Exception ex)
            {
                result += "\r\n Error sending mail: \r\n" + ex.Message;
            }

            return(result);
        }
예제 #4
0
        private string Process()
        {
            var    dateStr = DateTime.UtcNow.ToString("yyyy.MM.dd HH.mm.ss");
            string result  = "Request at " + DateTime.UtcNow.ToString() + "\r\n";

            var queryValues = Request.RequestUri.ParseQueryString();

            result += "GET params: \r\n";

            foreach (var key in queryValues.AllKeys)
            {
                var value = queryValues[key];
                result += key + "=" + (value ?? "NULL") + "\r\n";
            }

            if (Request.Content != null)
            {
                var    buffer   = Request.Content.ReadAsByteArrayAsync().Result;
                object postData = Encoding.UTF8.GetString(buffer);
                if (postData != null)
                {
                    result += "\r\nPOST data: \r\n" + postData;
                }
            }

            var mail = new MailMessage();

            mail.Subject = "Call Summary " + dateStr;
            mail.AddRecipients(ConfigurationManager.AppSettings["Receivers"]);
            mail.Body = result;

            try
            {
                new SmtpClient().Send(mail);
            }
            catch (Exception ex)
            {
                result += "\r\n Error sending mail: \r\n" + ex.ToString();
            }

            return(result);
        }
예제 #5
0
파일: Logon.cs 프로젝트: yangyue1943/song
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //先检查当前mac是否存在用户
            string         ip       = WSH.Windows.Common.HardwareInfo.GetNetCardIP();
            string         mac      = WSH.Windows.Common.HardwareInfo.GetMacAddress();
            UserInfoEntity userInfo = null;

            try
            {
                loading.Show(this);
                CodeBuilderService service = ServiceHelper.GetCodeBuilderService();
                userInfo = service.GetUserInfo(new UserInfoEntity()
                {
                    IPAddress  = ip,
                    MacAddress = mac
                });
                loading.Hide();
            }
            catch (Exception ex) {
                loading.Hide();
                MsgBox.Alert("获取用户信息失败,错误信息:" + ex.Message);
            }
            if (userInfo != null && userInfo.ID > 0)
            {
                string sendmail = userInfo.Email;
                if (string.IsNullOrEmpty(sendmail))
                {
                    //存在用户则发送邮件
                    Prompt p = new Prompt()
                    {
                        Content = "请输入您的邮箱",
                        Height  = 100,
                        Width   = 250
                    };
                    p.OnCustomValidate += (s, r) =>
                    {
                        if (!RegexHelper.Test(r.Value, RegexHelper.Email))
                        {
                            r.Msg       = "邮箱格式不正确!";
                            r.IsSuccess = false;
                        }
                    };
                    sendmail = p.Show();
                }
                if (!string.IsNullOrEmpty(sendmail))
                {
                    loading.Show(this);
                    try
                    {
                        SmtpConfig  config     = SmtpConfigManager.GetDefaultConfig();
                        SmtpClient  smtpClient = SmtpConfigManager.GetSmtpClient(config);
                        MailMessage mail       = new MailMessage()
                        {
                            Subject    = "WSH.Studio找回用户名密码",
                            BodyFormat = MailFormat.Text,
                            From       = config.Username,
                            FromName   = config.SendName,
                            Body       = string.Format("您注册过的WSH.Studio用户名为:{0},密码为:{1}",
                                                       userInfo.UserName,
                                                       CryptHelper.DecryptDES(userInfo.Password, CryptHelper.DefaultKey))
                        };
                        mail.AddRecipients(sendmail);
                        bool isSend = smtpClient.Send(mail);
                        if (!isSend)
                        {
                            throw new Exception(smtpClient.ErrorMsg);
                        }
                        loading.Hide();
                        MsgBox.Alert("已经将用户名和密码成功发送到您的邮箱,请查收!");
                    }
                    catch (Exception ex)
                    {
                        loading.Hide();
                        MsgBox.Alert("找回用户名密码失败,请联系管理员,错误信息:" + ex.Message);
                    }
                }
            }
            else
            {
                MsgBox.Alert("您本机还没有注册过账号,请先注册!");
            }
        }