Exemplo n.º 1
0
 private void EMP_ISERT_CANCEL_Click(object sender, EventArgs e)
 {
     NameSet.Clear();
     AgeSet.Value     = 20;
     SalarySet.Value  = 5000;
     PremiumSet.Value = 0;
     PhoneSet.Clear();
     EmailSet.Clear();
     Dep_IdSET.Value = 0;
     label22.Visible = false;
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            EmailSet model = MyXmlSerializer <EmailSet> .Get(fileUrl);

            RadioBtnOpenOrClose.SelectedValue = model.openOrcloseWeb.ToString();
            TbEmialName.Text   = model.EmailName;
            TbEmailPwd.Text    = model.EmailPwd;
            TbSMTPAddress.Text = model.SMTP;
            TbPort.Text        = model.Port;
        }
    }
 public PlanningCenterClient(PlanningCenterOptions options, PlanningCenterToken token)
 {
     System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11;
     People             = new PeopleSet(options, token);
     MaritalStatuses    = new MaritalStatusSet(options, token);
     Households         = new HouseholdSet(options, token);
     Emails             = new EmailSet(options, token);
     FieldDefinitions   = new FieldDefinitionSet(options, token);
     PhoneNumbers       = new PhoneNumberSet(options, token);
     Addresses          = new AddressSet(options, token);
     Campuses           = new CampusSet(options, token);
     Giving             = new GivingRealm(options, token);
     MembershipStatuses = new MembershipStatusSet(options, token);
 }
Exemplo n.º 4
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        #region
        EmailSet model = new EmailSet();
        model.openOrcloseWeb = RadioBtnOpenOrClose.SelectedValue.ToInt();
        model.EmailName      = TbEmialName.Text.TrimEnd();
        model.EmailPwd       = TbEmailPwd.Text.TrimEnd();
        model.SMTP           = TbSMTPAddress.Text.TrimEnd();
        model.Port           = TbPort.Text.TrimEnd();
        MyXmlSerializer <EmailSet> .Set(model, fileUrl);

        MessageDiv.InnerHtml = YK.Common.CommonClass.Alert("数据修改成功!");
        #endregion
    }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="content">发送内容</param>
        /// <param name="toEmail">目标邮件,多邮件发送以“;”号隔开</param>
        /// <returns></returns>
        public static bool SendEmail(string title, string content, string toEmail, string fileName)
        {
            try
            {
                string   fileUrl = HttpContext.Current.Server.MapPath("~/App_Data/WebSet/EmailSet.xml");
                EmailSet es      = MyXmlSerializer <EmailSet> .Get(fileUrl);

                MailAddress from  = new MailAddress(es.EmailName);
                MailAddress reply = new MailAddress(es.EmailName);
                foreach (string add in toEmail.Split(';'))
                {
                    MailAddress to   = new MailAddress(add);
                    MailMessage msg1 = new MailMessage(from, to);
                    msg1.ReplyTo      = reply;
                    msg1.Subject      = title;
                    msg1.Body         = content;
                    msg1.BodyEncoding = System.Text.Encoding.UTF8;
                    msg1.IsBodyHtml   = true;
                    //msg1.Sender = sender;

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        Attachment attachment = new Attachment(fileName);
                        msg1.Attachments.Add(attachment);
                    }

                    SmtpClient client = new SmtpClient(es.SMTP, es.Port.ToInt());//SMTP地址,"端口号"
                    client.Credentials = new NetworkCredential(es.EmailName, es.EmailPwd);
                    client.Send(msg1);
                }
                return(true);
            }
            catch (Exception ex)
            {
                //写入日志
                TxtFileHelper.AppendLogTxt(ex.Message);
                return(false);
            }
        }
Exemplo n.º 6
0
        private async void EMP_INSERT_OK_Click(object sender, EventArgs e)
        {
            if (label22.Visible)
            {
                label22.Visible = false;
            }

            if (!string.IsNullOrEmpty(NameSet.Text) && !string.IsNullOrWhiteSpace(NameSet.Text) &&
                !string.IsNullOrEmpty(PhoneSet.Text) && !string.IsNullOrWhiteSpace(PhoneSet.Text) &&
                !string.IsNullOrEmpty(EmailSet.Text) && !string.IsNullOrWhiteSpace(EmailSet.Text) &&
                Dep_IdSET.Value != 0)
            {
                SqlCommand command = new SqlCommand("INSERT INTO [Employees](Name,Age,Salary,Premium,PhoneNumber,Email,Dep_Id)" +
                                                    "Values(@Name,@Age,@Salary,@Premium,@PhoneNumber,@Email,@Dep_Id)", sqlconnection);

                command.Parameters.AddWithValue("Name", NameSet.Text);
                command.Parameters.AddWithValue("Age", AgeSet.Value);
                command.Parameters.AddWithValue("Salary", SalarySet.Value);
                command.Parameters.AddWithValue("Premium", PremiumSet.Value);
                command.Parameters.AddWithValue("PhoneNumber", PhoneSet.Text);
                command.Parameters.AddWithValue("Email", EmailSet.Text);
                command.Parameters.AddWithValue("Dep_Id", Dep_IdSET.Value);

                await command.ExecuteNonQueryAsync();

                NameSet.Clear();
                AgeSet.Value     = 20;
                SalarySet.Value  = 5000;
                PremiumSet.Value = 0;
                PhoneSet.Clear();
                EmailSet.Clear();
                Dep_IdSET.Value = 0;
            }
            else
            {
                label22.Visible = true;
                label22.Text    = "поля введены не коректно";
            }
        }
Exemplo n.º 7
0
    /// <summary>
    /// 126邮件发送
    /// </summary>
    /// <param name="EmailList">邮件列表,以分号“;”隔开</param>
    /// <param name="title">标题</param>
    /// <param name="sendContent">发送内容</param>
    public static void MailSend(string EmailList, string title, string sendContent)
    {
        string   fileUrl = HttpContext.Current.Server.MapPath("~/App_Data/WebSet/EmailSet.xml");
        EmailSet es      = MyXmlSerializer <EmailSet> .Get(fileUrl);

        try
        {
            MailMessage objMailMessage = new MailMessage();
            // 创建邮件消息
            objMailMessage.From       = es.EmailName; //源邮件地址
            objMailMessage.To         = EmailList;    //目的邮件地址,也就是发给我哈
            objMailMessage.Subject    = title;        //发送邮件的标题
            objMailMessage.Body       = sendContent;  //发送邮件的内容
            objMailMessage.BodyFormat = MailFormat.Html;

            // 创建一个附件对象
            //MailAttachment objMailAttachmentobjMailAttachment = new MailAttachment("");//发送邮件的附件 --"d:\\test.txt"
            //objMailMessage.Attachments.Add(objMailAttachment);//将附件附加到邮件消息对象中

            //接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本
            //基本权限
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            //用户名
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", es.EmailName);
            //密码
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", es.EmailPwd);
            //如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied
            //SMTP地址
            SmtpMail.SmtpServer = es.SMTP;
            //开始发送邮件
            SmtpMail.Send(objMailMessage);
        }
        catch (Exception ex)
        {
            //写入日志
            TxtFileHelper.AppendLogTxt(ex.Message);
        }
    }
        public async Task <JsonResult> SendEmail(EmailIM vm)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }

            if (Session["SigCaptcha"] != null && Session["SigCaptcha"].ToString().ToLower() != vm.CaptchaText.ToLower())
            {
                ModelState.AddModelError(string.Empty, "验证码不正确!");
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
                // return View(model);
            }

            var template = await _db.EmailTemplateSets.FirstOrDefaultAsync(d => d.TemplateNo == "T003");

            // _templateService.GetEmailTemplateByTemplateNo("T003");
            if (template == null)
            {
                AR.Setfailure(string.Format(Messages.NoEmailTemplate, "T003"));
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }


            vm.Subject = SettingsManager.Site.SiteName + "联系邮件";
            var emailBody = ReplaceTemplate(template.Body);

            emailBody = emailBody.Replace("{Name}", vm.Name);
            emailBody = emailBody.Replace("{Phone}", vm.Phone);
            emailBody = emailBody.Replace("{Email}", vm.Email);
            emailBody = emailBody.Replace("{Message}", vm.Body);

            var emailAccount = await _db.EmailAccountSets.FindAsync(template.EmailAccountId);

            //_accountService.GetById(template.EmailAccountId);

            try
            {
                EmailSet email = new EmailSet
                {
                    Body        = emailBody,
                    Subject     = vm.Subject,
                    MailTo      = vm.Email,
                    MailCc      = string.Empty,
                    Active      = true,
                    CreatedBy   = vm.Name,
                    CreatedDate = DateTime.Now
                };

                _db.EmailSets.Add(email);
                await _db.SaveChangesAsync();

                // _emailListService.Create(email);

                _emailService.SendMail(vm.Name, vm.Email, SettingsManager.Site.MailTo, string.Empty,
                                       vm.Subject, emailBody, emailAccount.Smtpserver, emailAccount.Email, SettingsManager.Site.SiteName,
                                       emailAccount.UserName, EncryptionHelper.Decrypt(emailAccount.Password), (int)emailAccount.Port, emailAccount.EnableSsl);


                AR.SetSuccess(Messages.EmailSentSuccess);
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
            catch (Exception er)
            {
                AR.Setfailure(er.Message);
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
        }