public async Task <ActionResult <Customer> > Excute()
        {
            var _context = new TGDDContext();

            var newCustomerId = _context.Customers.Max(c => c.Id) + 1;

            Customer.Id       = newCustomerId;
            Customer.Password = SecurityUtils.CreateMD5(Customer.Password);

            _context.Customers.Add(Customer);
            try
            {
                await _context.SaveChangesAsync();

                {
                    MailClass mailClass = GetMailObject(Customer);
                    await _mailService.SendMail(mailClass);
                }
            }
            catch (DbUpdateException)
            {
                bool customerExist = _context.Customers.Any(c => c.Id == Customer.Id);
                if (customerExist)
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetCustomers", new { id = Customer.Id }, Customer));
        }
        public async Task <string> SendMail(MailClass mailClass)
        {
            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(mailClass.FromMail);
                    mailClass.ToMails.ForEach(x =>
                    {
                        mail.To.Add(x);
                    });

                    mail.Subject    = mailClass.Subject;
                    mail.Body       = mailClass.Body;
                    mail.IsBodyHtml = mailClass.IsBodyHtml;
                    mailClass.Attachments.ForEach(x =>
                    {
                        mail.Attachments.Add(new Attachment(x));
                    });

                    using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                    {
                        smtp.Credentials = new System.Net.NetworkCredential(mailClass.FromMail, mailClass.FromMailPassword);
                        smtp.EnableSsl   = true;
                        await smtp.SendMailAsync(mail);

                        return(MessageMail.MailSent);
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Example #3
0
        private void SaveSetting()
        {
            MailClass mail     = new MailClass();
            string    Username = Request.Cookies["Username"].Value.ToString();

            try
            {
                if (mail.ExtClearSettings(Username))
                {
                    mail.ExtSaveSetting(Username, this.txtTitle1.Text, this.txtEmail1.Text, true, "", "", "", "21", this.txtPopSvrName1.Text, this.txtPopUserName1.Text, (this.txtPopPwd1.Text != "")?this.txtPopPwd1.Text:this.lblPwd1.Value, Int32.Parse(this.txtPort1.Text), this.chkDelSvrMsg1.Checked, this.chkDownNew1.Checked, Int32.Parse(this.txtTimeOut1.Text), 1);
                    mail.ExtSaveSetting(Username, this.txtTitle2.Text, this.txtEmail2.Text, true, "", "", "", "21", this.txtPopSvrName2.Text, this.txtPopUserName2.Text, (this.txtPopPwd2.Text != "")?this.txtPopPwd2.Text:this.lblPwd2.Value, Int32.Parse(this.txtPort2.Text), this.chkDelSvrMsg2.Checked, this.chkDownNew2.Checked, Int32.Parse(this.txtTimeOut2.Text), 2);
                    mail.ExtSaveSetting(Username, this.txtTitle3.Text, this.txtEmail3.Text, true, "", "", "", "21", this.txtPopSvrName3.Text, this.txtPopUserName3.Text, (this.txtPopPwd3.Text != "")?this.txtPopPwd3.Text:this.lblPwd3.Value, Int32.Parse(this.txtPort3.Text), this.chkDelSvrMsg3.Checked, this.chkDownNew3.Checked, Int32.Parse(this.txtTimeOut3.Text), 3);
                }
                else
                {
                    Server.Transfer("../../../Error.aspx");
                }
            }
            catch (Exception ex)
            {
                UDS.Components.Error.Log(ex.ToString());
                Server.Transfer("../../../Error.aspx");
            }
            mail = null;
        }
Example #4
0
        public async Task <string> SendMail(MailClass mailClass)
        {
            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(mailClass.FromMail);
                    mailClass.ToMails.ForEach(m =>
                    {
                        mail.To.Add(m);
                    });
                    mail.Subject    = mailClass.Subject;
                    mail.Body       = mailClass.Body;
                    mail.IsBodyHtml = mailClass.IsBodyHtml;
                    using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                    {
                        smtp.Credentials = new NetworkCredential(mailClass.FromMail, mailClass.FromMailPassword);
                        smtp.EnableSsl   = true;
                        await smtp.SendMailAsync(mail);

                        return("Сообщение отправлено");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #5
0
        /// <summary>
        /// 回复邮件设置
        /// </summary>
        private void ReplySet()
        {
            // 读取原邮件内容
            MailClass     mailclass  = new MailClass();
            SqlDataReader dataReader = null;

            try
            {
                dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }

            if (dataReader.Read())
            {
                string tmpStr = "<br/>" + dataReader[7].ToString();
                tmpStr = tmpStr.Replace("<br/>", "\r\n>");
                this.txtSubject.Text = "Re:" + dataReader[4].ToString();
                SendToRealName       = dataReader[1].ToString() + ",";
                SendTo             = dataReader[10].ToString() + ",";
                this.txtBody.Text  = SendToRealName + "你好!\n\n\n\n\n\n\n";
                this.txtBody.Text += "=======" + dataReader[3].ToString() + "你在来信中写道:" + "=======\n\n";
                this.txtBody.Text += tmpStr;
            }
            dataReader.Close();
            mailclass = null;
        }
        public string PostSendMail(User user, MailClass temp)
        {
            SmtpClient client = new SmtpClient();

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl      = true;
            client.Host           = "smtp.gmail.com";
            client.Port           = 587;
            // setup Smtp authentication
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential("*****@*****.**", "mayank123");
            client.UseDefaultCredentials = false;
            client.Credentials           = credentials;
            //int demo = 0;
            //can be obtained from your model
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("*****@*****.**");
            msg.To.Add(new MailAddress(user.Email));
            msg.Subject    = temp.subject;
            msg.IsBodyHtml = true;
            msg.Body       = temp.message;
            try
            {
                client.Send(msg);
                return("OK");
            }
            catch (Exception ex)
            {
                return("error:" + ex.ToString());
            }
        }
Example #7
0
 public static EmailSendRecordInfo SendEmail(EmailSendRecordInfo emailSendRecord)
 {
     foreach (string str in emailSendRecord.EmailList.Split(new char[] { ',' }))
     {
         if (str != string.Empty)
         {
             MailInfo mail = new MailInfo();
             mail.ToEmail = str;
             mail.Title   = emailSendRecord.Title;
             mail.Content = emailSendRecord.Content;
             if (emailSendRecord.IsStatisticsOpendEmail == 1)
             {
                 object content = mail.Content;
                 mail.Content = string.Concat(new object[] { content, "<img style=\"display:none\" src=\"http://", HttpContext.Current.Request.ServerVariables["Http_Host"], "/Admin/EmailCheckOpen.aspx?Email=", str, "&ID=", emailSendRecord.ID, "\" >" });
             }
             mail.UserName   = ShopConfig.ReadConfigInfo().EmailUserName;
             mail.Password   = ShopConfig.ReadConfigInfo().EmailPassword;
             mail.Server     = ShopConfig.ReadConfigInfo().EmailServer;
             mail.ServerPort = ShopConfig.ReadConfigInfo().EmailServerPort;
             try
             {
                 MailClass.SendEmail(mail);
             }
             catch (Exception exception)
             {
                 ExceptionHelper.ProcessException(exception, true);
             }
         }
     }
     emailSendRecord.SendDate   = RequestHelper.DateNow;
     emailSendRecord.SendStatus = 3;
     SaveEmailSendRecordStatus(emailSendRecord);
     return(emailSendRecord);
 }
Example #8
0
        public async Task <IActionResult> SignUp([FromBody] LoginInfo oLoginInfo)
        {
            string sMessage = "";
            var    user     = await _loginInfoService.SignUp(oLoginInfo);

            if (user == null)
            {
                return(BadRequest(new { message = Message.ErrorFound }));
            }
            if (user.Message == Message.VerifyEmail)
            {
                MailClass oMailClass = this.GetMailObject(user);
                await _mailService.SendMail(oMailClass);

                return(BadRequest(new { message = Message.VerifyEmail }));
            }

            #region Send Confirmation Mail
            if (user.Message == Message.Success)
            {
                MailClass oMailClass = this.GetMailObject(user);
                sMessage = await _mailService.SendMail(oMailClass);
            }
            if (sMessage != Message.MailSent)
            {
                return(BadRequest(new { message = sMessage }));
            }
            else
            {
                return(Ok(new { message = Message.UserCreatedVerifyEmail }));
            }

            #endregion
        }
Example #9
0
 /// <summary>
 /// 对下拉列表进行初始化
 /// </summary>
 private void PopulateListView()
 {
     listFolderType.Items.Clear();
     listFolderType.Items.Add(new ListItem("放入邮件夹...", "0"));
     listFolderType.Items.Add(new ListItem("收件夹", "1"));
     listFolderType.Items.Add(new ListItem("已经发送的邮件", "2"));
     listFolderType.Items.Add(new ListItem("废件夹", "3"));
     if (this.listExtMail.Visible)
     {
         try
         {
             MailClass mail = new MailClass();
             this.listExtMail.DataTextField  = "Title";
             this.listExtMail.DataValueField = "OrderID";
             this.listExtMail.DataSource     = mail.ExtGetAvaSetting(Request.Cookies["Username"].Value.ToString());
             this.listExtMail.DataBind();
             this.listExtMail.Items.Insert(0, "全部外部邮箱");
             this.listExtMail.Items.FindByText("全部外部邮箱").Value = "0";
             this.listExtMail.SelectedIndex = 0;
         }
         catch (Exception ex)
         {
             UDS.Components.Error.Log(ex.ToString());
             Server.Transfer("../../Error.aspx");
         }
     }
 }
        public IHttpActionResult AddAccount([FromBody] Account account)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                _accountRepository.Add(account);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ProjectContext _projectContext = new ProjectContext();
            var            user            = _projectContext.Users
                                             .Where(u => u.UserID == account.UserID)
                                             .FirstOrDefault();
            MailClass mail = new MailClass();

            mail.subject = "Account Approved";
            mail.message = "Congratulations! Your account has been approved.\nUse these credentials to login into your account.\n" + "UserID : " + account.UserID + "\n" + "Login Password : " + account.LoginPassword;
            string res = _accountRepository.PostSendMail(user, mail);

            return(Ok(account));
        }
 /// <summary>
 /// 发送Email,保存发送状态,发送时间
 /// </summary>
 /// <param name="emailSendRecord"></param>
 public static EmailSendRecordInfo SendEmail(EmailSendRecordInfo emailSendRecord)
 {
     //发送
     foreach (string temp in emailSendRecord.EmailList.Split(','))
     {
         if (temp != string.Empty)
         {
             MailInfo mail = new MailInfo();
             mail.ToEmail = temp;
             mail.Title   = emailSendRecord.Title;
             mail.Content = emailSendRecord.Content;
             if (emailSendRecord.IsStatisticsOpendEmail == (int)BoolType.True)
             {
                 mail.Content += "<img style=\"display:none\" src=\"http://" + HttpContext.Current.Request.ServerVariables["Http_Host"] + "/Admin/EmailCheckOpen.aspx?Email=" + temp + "&ID=" + emailSendRecord.ID + "\" >";
             }
             mail.UserName   = ShopConfig.ReadConfigInfo().EmailUserName;
             mail.Password   = ShopConfig.ReadConfigInfo().EmailPassword;
             mail.Server     = ShopConfig.ReadConfigInfo().EmailServer;
             mail.ServerPort = ShopConfig.ReadConfigInfo().EmailServerPort;
             try
             {
                 MailClass.SendEmail(mail);
             }
             catch (Exception ex)
             {
                 ExceptionHelper.ProcessException(ex, true);
             }
         }
     }
     //保存状态
     emailSendRecord.SendDate   = RequestHelper.DateNow;
     emailSendRecord.SendStatus = (int)SendStatus.Finished;
     EmailSendRecordBLL.SaveEmailSendRecordStatus(emailSendRecord);
     return(emailSendRecord);
 }
        public ObservableCollection <MailClass> GetAll(int Count, int returnMessage)
        {
            bool Flag;

            if (Count >= folderMail.Count || Count <= 0)
            {
                return(mailClasses);
            }
            mailClasses = new ObservableCollection <MailClass>();
            for (int i = Count; i > Count - returnMessage; i--)
            {
                if (i > folderMail.Count || i <= 0)
                {
                    return(mailClasses);
                }
                var  message        = client.Inbox.GetMessage(i);
                char CharFrom       = message.From.ToString().ToArray()[1];
                var  folderMailInfo = client.Inbox.Fetch(new[] { i }, MessageSummaryItems.Flags);
                if (folderMailInfo[0].Flags.ToString() == "Seen")
                {
                    Flag = false;
                }
                else
                {
                    Flag = true;
                }
                MailClass mailClass = new MailClass(i, message.Subject, message.From.ToString(), CharFrom, message.HtmlBody, message.TextBody, message.Date.DateTime, false, Flag);
                mailClasses.Add(mailClass);
            }
            return(mailClasses);
        }
Example #13
0
        public void SendMail()
        {
            MailClass   objMail     = this.GetMailConfiguration();
            string      server      = objMail.SMTPSever;
            string      pnumber     = (this.txtMailPhone.Text == "" ? "<not provided>" : this.txtMailPhone.Text);
            MailAddress to          = new MailAddress(objMail.ToMail);
            MailAddress from        = new MailAddress(this.txtMailEmail.Text);
            MailMessage message     = new MailMessage(from, to);
            string      contactform = (this.rdContact1.Checked ? "Email" : "Phone number");

            message.Subject = String.Format("Real Estate:{0}", this.drpMailIssue.SelectedItem.Text);
            string BodyMessage = String.Format("Client: {0}\r\nEmail: {1}\r\nPhone: {2}" +
                                               "\r\nContact me by: {3} \r\n********************", this.txtMailName.Text, this.txtMailEmail.Text,
                                               pnumber, contactform);

            message.Body = String.Format("{0}\r\nMessage:\r\n{1}", BodyMessage, this.txtMailComment.Text);
            // Add a carbon copy recipient.
            //MailAddress copy = new MailAddress("*****@*****.**");
            //message.CC.Add(copy);

            SmtpClient client = new SmtpClient(server);

            // Include credentials if the server requires them.
            client.Credentials = new  NetworkCredential(objMail.Mailuser, objMail.MailPswd);
            client.Send(message);
        }
Example #14
0
        public void MailTest()
        {
            MailClass mail = new MailClass();

            bool succes = mail.SendMail("*****@*****.**", "JorenSchelkens", Guid.NewGuid().ToString());

            Assert.True(succes);
        }
Example #15
0
        /// <summary>
        /// 撤回
        /// </summary>
        private void afterSendCh()
        {
            string _Head_Tbl_Name = "";
            string _Body_Tbl_Name = "";

            try
            {
                _Head_Tbl_Name = "[" + HeadTemp + "]";
                _Body_Tbl_Name = "[" + BodyTemp + "]";

                StringBuilder strSql = new StringBuilder();
                strSql.Append(" Exec dbo.usp_ShippingInfoConfirmOrder_Rev @Pgm_Id='ShippingInfoConfirmOrder',");
                strSql.Append("   @Company_Id='" + LoginInfo._Usr_Company + "', ");
                strSql.Append("   @Shipping_Id='" + this.Shipping_Id.Text + "',");
                strSql.Append("       @Loaded_Head_Tbl_Name='" + _Head_Tbl_Name + "', ");
                strSql.Append("       @Loaded_Body_Tbl_Name='" + _Body_Tbl_Name + "', ");
                strSql.Append("    @User_Id='" + LoginInfo._Usr_id + "'  ");

                DataTable _dtRusult = SqlHelper.ExecuteDataTable(strSql.ToString());
                if (_dtRusult != null && _dtRusult.Rows.Count > 0)
                {
                    string _msg = "";
                    if (_dtRusult.Columns.Contains("Error_Msg"))
                    {
                        _msg = _dtRusult.Rows[0]["Error_Msg"].ToString();
                    }

                    if (!string.IsNullOrEmpty(_msg))
                    {
                        MessageBox.Show("出现错误:" + _msg);
                        return;
                    }
                    else
                    {
                        Dictionary <string, object> _ht = new Dictionary <string, object>();
                        _ht["SEND_SERVER_IP"]      = _dtRusult.Rows[0]["SEND_SERVER_IP"].ToString();
                        _ht["SEND_PORT"]           = _dtRusult.Rows[0]["SEND_PORT"].ToString();
                        _ht["SEND_EMAIL_ID"]       = _dtRusult.Rows[0]["SEND_EMAIL_ID"].ToString();
                        _ht["SEND_PASSWORD"]       = _dtRusult.Rows[0]["SEND_PASSWORD"].ToString();
                        _ht["RECIPIENT_EMAIL_IDS"] = _dtRusult.Rows[0]["RECIPIENT_EMAIL_IDS"].ToString();
                        _ht["CC_EMAIL_IDS"]        = _dtRusult.Rows[0]["CC_EMAIL_IDS"].ToString();
                        MailClass.SendLargeMsg(tableLayoutPanel1, dataGridView1, "确认单", _ht);
                    }
                }
            }
            catch (Exception _ex)
            {
                MessageBox.Show(_ex.Message.ToString());
            }
            finally
            {
                StringBuilder strDel = new StringBuilder();
                strDel.Append("DROP TABLE " + _Head_Tbl_Name + ";");
                strDel.Append("DROP TABLE " + _Body_Tbl_Name + ";");
                SqlHelper.ExecuteQuery(strDel.ToString());
            }
        }
Example #16
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            MailClass mail    = new MailClass();
            bool      sqlFlag = true;
            string    sql     = "";

            foreach (DataGridItem dgi in dgMailList.Items)
            {
                CheckBox cb = (CheckBox)(dgi.Cells[0].Controls[1]);
                if (cb.Checked == true)
                {
                    int    i  = dgi.ItemIndex;
                    string id = dgMailList.DataKeys[i].ToString();
                    if (sqlFlag)
                    {
                        sql    += " MailID= '" + id + "'";
                        sqlFlag = false;
                    }
                    else
                    {
                        sql += " or";
                        sql += " MailID= '" + id + "'";
                    }
                }
            }
            //选择为空
            if (sql == String.Empty)
            {
                Response.Write("<script language=javascript>alert('请选择邮件!');window.location='Index.aspx?FolderType=" + Session["FolderType"].ToString() + "';</script>");
            }
            else
            {
                try
                {
                    if (Session["FolderType"].ToString() == "3")
                    {
                        mail.MailDelete(sql, 1);                       //彻底删除
                    }
                    else if (Session["FolderType"].ToString() == "4")
                    {
                        mail.MailDelete(sql, 40);
                    }
                    else
                    {
                        mail.MailDelete(sql, 0);                       //丢到废件箱
                    }

                    Response.Write("<script language=javascript>alert('邮件删除成功!');window.location='Index.aspx?FolderType=" + Session["FolderType"].ToString() + "';</script>");
                }
                catch (Exception ex)
                {
                    UDS.Components.Error.Log(ex.ToString());
                    Server.Transfer("../../Error.aspx");
                }
            }
            mail = null;
        }
Example #17
0
        /// <summary>
        /// 转发邮件设置
        /// </summary>
        private void ForwardSet()
        {
            // 读取原邮件内容
            MailClass     mailclass  = new MailClass();
            SqlDataReader dataReader = null;

            try
            {
                dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }

            if (dataReader.Read())
            {
                string tmpStr = "<br/>" + dataReader[7].ToString();
                tmpStr = tmpStr.Replace("<br/>", "\r\n>");
                this.txtSubject.Text = "Fw::" + dataReader[4].ToString();
                this.txtBody.Text    = ",你好!\n\n\n\n\n\n\n";
                this.txtBody.Text   += "=======下面是转发邮件=======\n";
                this.txtBody.Text   += "原邮件发件人姓名:" + dataReader[1].ToString() + "\n";
                this.txtBody.Text   += "原邮件发件人代号:" + dataReader[10].ToString() + "\n";
                this.txtBody.Text   += tmpStr;
            }
            dataReader.Close();



            try
            {
                dataReader = mailclass.GetMailAttInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }
            while (dataReader.Read())
            {
                UDS.Components.MailAttachFile att = new MailAttachFile();
                att.FileAttribute  = 0;
                att.FileSize       = Int32.Parse(dataReader[1].ToString());
                att.FileName       = dataReader[0].ToString();
                att.FileAuthor     = Username;
                att.FileCatlog     = "邮件";
                att.FileVisualPath = dataReader[2].ToString();
                upattlist.Add(att);
            }
            BindAttList();


            dataReader.Close();


            mailclass = null;
        }
Example #18
0
        private bool DelteAudit(string Company_Id, string Bil_id)
        {
            bool   isEor          = true;
            string _Head_Tbl_Name = "";
            string _Body_Tbl_Name = "";

            try
            {
                _Head_Tbl_Name = "[" + HeadTemp + "]";
                _Body_Tbl_Name = "[" + BodyTemp + "]";
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" Exec dbo.usp_TaskNotifyOrder_Del @Pgm_Id='TaskNotifyOrder',    ");
                strSql.Append("   @Company_Id='" + Company_Id + "', ");
                strSql.Append("   @Notify_Id='" + Bil_id + "',");
                strSql.Append("				@Loaded_Head_Tbl_Name='"+ HeadTemp + "',  ");
                strSql.Append("                  @Loaded_Body_Tbl_Name='" + BodyTemp + "'  ");

                DataTable _dtRusult = SqlHelper.ExecuteDataTable(strSql.ToString());
                if (_dtRusult != null && _dtRusult.Rows.Count > 0)
                {
                    string _msg = "";
                    if (_dtRusult.Columns.Contains("Error_Msg"))
                    {
                        _msg = _dtRusult.Rows[0]["Error_Msg"].ToString();
                    }

                    if (!string.IsNullOrEmpty(_msg))
                    {
                        MessageBox.Show("出现错误:" + _msg);
                        isEor = false;
                    }
                    else
                    {
                        Dictionary <string, object> _ht = new Dictionary <string, object>();
                        _ht["SEND_SERVER_IP"]      = _dtRusult.Rows[0]["SEND_SERVER_IP"].ToString();
                        _ht["SEND_PORT"]           = _dtRusult.Rows[0]["SEND_PORT"].ToString();
                        _ht["SEND_EMAIL_ID"]       = _dtRusult.Rows[0]["SEND_EMAIL_ID"].ToString();
                        _ht["SEND_PASSWORD"]       = _dtRusult.Rows[0]["SEND_PASSWORD"].ToString();
                        _ht["RECIPIENT_EMAIL_IDS"] = _dtRusult.Rows[0]["RECIPIENT_EMAIL_IDS"].ToString();
                        _ht["CC_EMAIL_IDS"]        = _dtRusult.Rows[0]["CC_EMAIL_IDS"].ToString();
                        MailClass.SendLargeMsg(tableLayoutPanel1, dataGridView1, "需求单", _ht);
                    }
                }
            }
            catch (Exception _ex)
            {
                MessageBox.Show(_ex.Message.ToString());
            }
            finally
            {
                StringBuilder strDel = new StringBuilder();
                strDel.Append("DROP TABLE [" + HeadTemp + "];");
                strDel.Append("DROP TABLE [" + BodyTemp + "];");
                SqlHelper.ExecuteQuery(strDel.ToString());
            }
            return(isEor);
        }
Example #19
0
    public static void EventMail(string EventName, string Description, DateTime fromeventdate, DateTime toevnetdate)
    {
        try
        {
            SqlProcsNew sqlobj = new SqlProcsNew();

            string  tomail       = "";
            string  touser       = "";
            string  title        = "";
            string  AdminName    = "";
            string  AdminContact = "";
            DataSet dsAdmin      = new DataSet();
            dsAdmin = sqlobj.ExecuteSP("GetAdminDetails");
            if (dsAdmin != null && dsAdmin.Tables[0].Rows.Count > 0)
            {
                AdminName    = dsAdmin.Tables[0].Rows[0]["CommunityName"].ToString();
                AdminContact = dsAdmin.Tables[0].Rows[0]["FromMobileNo"].ToString();
            }
            DataSet dsemail = sqlobj.ExecuteSP("SP_GetResidentMail");
            if (dsemail.Tables[0].Rows.Count > 0)
            {
                tomail = dsemail.Tables[0].Rows[0]["Contactmail"].ToString();
                touser = dsemail.Tables[0].Rows[0]["RTName"].ToString();
                title  = dsemail.Tables[0].Rows[0]["RTTitle"].ToString();

                dsemail.Dispose();

                if (tomail.ToString() != "")
                {
                    string strmcusername = "";
                    string strmcpassword = "";
                    string strmcfromname = "";

                    DataSet dsmc = sqlobj.ExecuteSP("SP_GetMailCredential");


                    if (dsmc.Tables[0].Rows.Count > 0)
                    {
                        strmcusername = dsmc.Tables[0].Rows[0]["username"].ToString();
                        strmcpassword = dsmc.Tables[0].Rows[0]["password"].ToString();
                        strmcfromname = dsmc.Tables[0].Rows[0]["sentbyuser"].ToString();
                    }

                    dsmc.Dispose();

                    MailClass M = new MailClass();
                    M.EventsMail(strmcusername, strmcfromname, tomail.ToString(), touser.ToString(), touser.ToString(), EventName.ToString(), Description.ToString(),
                                 fromeventdate, strmcusername.ToString(), strmcpassword.ToString(), AdminName, AdminContact, AdminContact, title);
                }
            }
        }
        catch (Exception ex)
        {
            WebMsgBox.Show(ex.Message);
        }
    }
Example #20
0
        protected void ShowBodyDetail()
        {
            MailClass     mailclass  = new MailClass();
            SqlDataReader dataReader = null;

            try
            {
                dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }

            if (dataReader.Read())
            {
                this.lblSenderName.Text = dataReader["MailSender"].ToString();
                this.lblCcToAddr.Text   = UDS.Components.Staff.GetRealNameStrByUsernameStr(dataReader["MailCcToAddr"].ToString(), 0);
                // 判断是否显示密抄人信息给本用户
                string[] RecvAr = System.Text.RegularExpressions.Regex.Split(dataReader["MailBccToAddr"].ToString(), ",");
                for (int i = 0; i < RecvAr.Length - 1; i++)
                {                       //判断密抄人中是否包含自己
                    if (RecvAr[i].ToString() == UserCookie.Value.ToString())
                    {
                        //this.lblBccToAddr.Text = UserCookie.Value.ToString();
                        this.lblBccToAddr.Text = UDS.Components.Staff.GetRealNameByUsername(UserCookie.Value.ToString());
                    }
                }

                this.lblSubject.Text     = dataReader["MailSubject"].ToString();
                this.lblBody.Text        = dataReader["MailBody"].ToString();
                this.lblSendDate.Text    = dataReader["MailSendDate"].ToString();
                this.lblReceiverStr.Text = UDS.Components.Staff.GetRealNameStrByUsernameStr(dataReader["MailReceiverStr"].ToString(), 0);
                this.lblProjectName.Text = dataReader["classname"].ToString();
            }
            dataReader.Close();

            // 开始读取附件信息

            try
            {
                dataReader = mailclass.GetMailAttInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }

            while (dataReader.Read())
            {
                lblAttachFile.Text += "&nbsp;<a href='Download.aspx?destFileName=" + Server.UrlEncode(dataReader[2].ToString()) + "'>" + dataReader[0].ToString() + "(" + dataReader[1].ToString() + " Byte)</a><br>";
            }
            dataReader.Close();

            mailclass = null;
        }
Example #21
0
    public void SendmailWithIcsAttachment(string touser, string customer, string reference, string comments, DateTime followupdate)
    {
        try
        {
            //public string Location { get; set; }
            string      Location = "";
            MailMessage msg      = new MailMessage();
            //Now we have to set the value to Mail message properties
            string  tomail  = "";
            DataSet dsemail = sqlobj.SQLExecuteDataset("SP_GetMailId",
                                                       new SqlParameter()
            {
                ParameterName = "@UserID", SqlDbType = SqlDbType.NVarChar, Value = touser.ToString()
            });


            if (dsemail.Tables[0].Rows.Count > 0)
            {
                tomail = dsemail.Tables[0].Rows[0]["StaffEmail"].ToString();
            }

            dsemail.Dispose();


            if (tomail.ToString() != "")
            {
                string strmcusername = "";
                string strmcpassword = "";
                string strmcfromname = "";


                DataSet dsmc = sqlobj.SQLExecuteDataset("SP_GetMailCredential");

                if (dsmc.Tables[0].Rows.Count > 0)
                {
                    strmcusername = dsmc.Tables[0].Rows[0]["username"].ToString();
                    strmcpassword = dsmc.Tables[0].Rows[0]["password"].ToString();
                    strmcfromname = dsmc.Tables[0].Rows[0]["sentbyuser"].ToString();
                }

                dsmc.Dispose();

                MailClass M = new MailClass();

                M.SendMail(strmcusername, strmcfromname, tomail.ToString(), touser.ToString(), customer, reference, comments,
                           followupdate, strmcusername.ToString(), strmcpassword.ToString());
            }
        }
        catch (Exception ex)
        {
            // CreateLogFiles Err = new CreateLogFiles();

            String[] contents = { ex.Message.ToString() };
            System.IO.File.WriteAllLines(Server.MapPath("error.txt"), contents);
        }
    }
        public IHttpActionResult BulkMail([FromBody] MailClass message)
        {
            var users = _adminRepository.GetUsers();
            var msg   = "";

            foreach (var u in users)
            {
                msg = _adminRepository.PostSendMail(u, message);
            }
            return(Ok(msg));
        }
        private MailClass GetMailObject(Customer Cus)
        {
            MailClass mailClass = new MailClass();

            mailClass.Subject   = "Hi, " + Cus.Lastname + " " + Cus.Firstname;
            mailClass.Body      = _mailService.GetMailBody(Cus);
            mailClass.ToMailIds = new List <string>()
            {
                Cus.Email,
            };
            return(mailClass);
        }
Example #24
0
        public ActionResult Edit(int Idmail)
        {
            MailRepository rep  = new MailRepository();
            MailClass      mail = rep.FetchByID(Idmail);

            if (mail == null)
            {
                return(HttpNotFound());
            }
            TempData["referrer"] = ControllerContext.RouteData.Values["referrer"];
            return(View(new MailModel(mail)));
        }
Example #25
0
        private void eMailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExtreXR rpr = new ExtreXR(frtID, dateEdit1.DateTime, dateEdit2.DateTime);

            if (string.IsNullOrWhiteSpace(rpr.eMails))
            {
                XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Firma Extre", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            rpti.put("EXTRE", "FRT", frtID, Program.USR, "F", "eMail");
            MailClass.MailReportTask(rpti, "eMail Firma Extre", rpr, rpr.eMails, rpr.eMailSubject, rpr.eMailBody);
        }
Example #26
0
        public static void MailNotice_Send(int u_id, string u_name, string u_email, string temppwd, string template)
        {
            bool isReg = !string.IsNullOrEmpty(temppwd);

            MailServersInfo mailServer = DataAccess.MailServers_SelectRand();

            string ml_title = "企业查询宝用户邮件认证";
            string ml_type  = "绑定邮箱认证";

            MailClass mc = new MailClass(mailServer.ms_smtp, mailServer.ms_port, mailServer.ms_ssl, mailServer.ms_loginName, mailServer.ms_loginPwd);

            string bodyContent = string.Empty;
            var    guid        = Guid.NewGuid();
            string code        = guid.ToString().Substring(0, 4);

            CacheHelper.Cache_Store("Email_" + u_id, code, TimeSpan.FromMinutes(10));
            bodyContent = string.Format("{0},您好:请点击如下链接,以完成您帐号的邮箱绑定,如无法点击请复制地址到浏览器中:<div style=\"font-Size:15px\">{1}</div>", u_email, "http://qiye.qianzhan.com/usercenter/SendEmail?code=" + code);

            //记录邮箱日志
            MailClass.MailInfo mailInfo = new MailClass.MailInfo()
            {
                from         = mailServer.ms_account,
                fromName     = System.Configuration.ConfigurationManager.AppSettings["mailFromName"],
                to           = u_email,
                toName       = u_name,
                title        = ml_title,
                body         = bodyContent,
                isBodyHtml   = true,
                userId       = u_id.ToString(),
                ml_type      = ml_type,
                sendComplete = new MailClass.OnSendComplete(OnSendComplete)
            };
            mc.SendMailAsync(mailInfo);

            ////记录邮箱日志
            //var maillog = new Users_MailLogInfo()
            //{
            //    ml_uid = Guid.NewGuid().ToString().Replace("-", "").Trim().Substring(0, 16),
            //    ml_type = ml_type,
            //    ml_to = u_email,
            //    ml_toName = u_name,
            //    ml_cc = string.Empty,
            //    ml_title = ml_title,
            //    ml_content = bodyContent,
            //    ml_resend = 0,
            //    ml_createTime = DateTime.Now,
            //    ml_createUser = u_id.ToString(),
            //    ml_from = mailServer.ms_account,
            //    ml_fromName = System.Configuration.ConfigurationManager.AppSettings["MailFromName"]
            //};
            //mc.SendMailAsync(mailInfo);
        }
Example #27
0
        private MailClass GetMailObject(LoginInfo userInfo)
        {
            MailClass mailClass = new MailClass();

            mailClass.Subject = "Mail Confirmation";
            mailClass.Body    = _mailService.GetMailBody(userInfo);
            mailClass.ToMails = new List <string>()
            {
                userInfo.Email
            };

            return(mailClass);
        }
Example #28
0
        private void YTeMailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int OPMid             = (int)opmGridView.GetFocusedRowCellValue(colOPMID);
            YuklemeTalimatiXR rpr = new YuklemeTalimatiXR(OPMid);

            if (string.IsNullOrWhiteSpace(rpr.eMails))
            {
                XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Yükleme Talimatı", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            rpti.put("YT", "OPM", OPMid, Program.USR, "F", "eMail");
            MailClass.MailReportTask(rpti, "eMail YüklemeTalimatı", rpr, rpr.eMails, rpr.eMailSubject, rpr.eMailBody);
        }
Example #29
0
        private void eMailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int            frtID = (int)gridView1.GetFocusedRowCellValue(colFRTID);
            BaBsMtkbtFrmXR rpr   = new BaBsMtkbtFrmXR(frtID, dateEdit1.DateTime, dateEdit2.DateTime);

            if (string.IsNullOrWhiteSpace(rpr.eMails))
            {
                XtraMessageBox.Show("eMail adresi bulunamadı", "eMail BaBs Mutabakat Formu", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            rpti.put("BABSMF", "FRT", frtID, Program.USR, "F", "eMail");
            MailClass.MailReportTask(rpti, "eMail BaBs Mutabakat Formu", rpr, rpr.eMails, rpr.eMailSubject, rpr.eMailBody);
        }
Example #30
0
        public MailClass GetMailObject(LoginInfo user)
        {
            MailClass oMailClass = new MailClass();

            oMailClass.Subject   = "Mail Confirmation";
            oMailClass.Body      = _mailService.GetMailBody(user);
            oMailClass.ToMailIds = new List <string>
            {
                user.EmailId
            };

            return(oMailClass);
        }
 protected bool sendmail()
 {
     //creating object of mailclass from mailclass.cs
     MailClass mymail = new MailClass();
     string Automessage = "Thank you for your request " + name + ". We will get back to you shortly";
     //string image = "Images/cem_logo.jpg";
     try
     {
         //mail_quote_wpc(name , from , to , cc , designation , company , contact , email , message , website);
         mymail = myclass.mail_quote(name , to , designation , company , contact , website , email , message , requestdate , formname);
         webclass.AutoMessage_customer(MailTextBox.Text , name , "CEM Business Solutions" , Automessage);
         return true;
     }
     catch (Exception ex)
     {
         resultLabel.Text = ex.ToString();
         return false;
     }
 }
Example #32
0
 protected bool sendmail()
 {
     //creating object of mailclass from mailclass.cs
     MailClass mymail = new MailClass();
     string Automessage = "Thank you for downloading our FAQ document";
     //string image = "Images/cem_logo.jpg";
     try
     {
         if (myclass.IsValidMail(MailTextBox.Text) == false)
         {
             if (formname == null || formname == string.Empty)
             {
                 formname = "contact";
                 //mail_quote_wpc(name , from , to , cc , designation , company , contact , email , message , website);
                 mymail = myclass.mail_quote(name, to, designation, company, contact, website, email, message, requestdate, formname);
                 webclass.AutoMessage_customer(MailTextBox.Text, name, "CEM Business Solutions", Automessage);
                 return true;
             }
             else
             {
                 mymail = myclass.mail_quote(name, to, designation, company, contact, website, email, message, requestdate, formname);
                 webclass.AutoMessage_customer(MailTextBox.Text, name, "CEM Business Solutions", Automessage);
                 return true;
             }
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         resultLabel.Text = ex.ToString();
         return true;
     }
 }
Example #33
0
    public MailClass mail_quotecc(string name, string cc, string to, string designation, string company, string contact, string website, string email, string message, DateTime requestdate, string formname)
    {
        MailClass customerDetails = new MailClass();
        customerDetails.nameField = name;
        customerDetails.fromField = "*****@*****.**";
        customerDetails.toField = to;
        customerDetails.ccField = cc;
        customerDetails.designationField = designation;
        customerDetails.companyField = company;
        customerDetails.contactField = contact;
        customerDetails.websiteField = website;
        customerDetails.emailField = email;
        customerDetails.messageField = message;
        customerDetails.requestdateField = requestdate;
        customerDetails.formnameField = formname;

        SmtpClient client = new SmtpClient();
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = true;
        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("*****@*****.**", "req@cembs@123");
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;

        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("*****@*****.**");
        msg.To.Add(new MailAddress(to));
        msg.CC.Add(new MailAddress(cc));
        msg.Subject = "Request from " + formname;
        msg.IsBodyHtml = true;

        if (website == "")
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            builder.AppendLine("<strong>" + "Name : " + "</strong>" + name + "<br />");
            builder.AppendLine("<strong>" + "Designation : " + "</strong>" + designation + "<br />");
            builder.AppendLine("<strong>" + "Company : " + "</strong>" + company + "<br />");
            builder.AppendLine("<strong>" + "Contact : " + "</strong>" + contact + "<br />");
            builder.AppendLine("<strong>" + "Email : " + "</strong>" + email + "<br />");
            //builder.AppendLine("<strong>" + "Message :" + "</strong>" + message);
            //builder.AppendLine("<strong>" + "Request for : " + "</strong>" + formname + "<br />");
            msg.Body = builder.ToString();
        }
        else
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            builder.AppendLine("<strong>" + "Name : " + "</strong>" + name + "<br />");
            builder.AppendLine("<strong>" + "Designation : " + "</strong>" + designation + "<br />");
            builder.AppendLine("<strong>" + "Company : " + "</strong>" + company + "<br />");
            builder.AppendLine("<strong>" + "Contact : " + "</strong>" + contact + "<br />");
            builder.AppendLine("<strong>" + "Website : " + "</strong>" + website + "<br />");
            builder.AppendLine("<strong>" + "Email : " + "</strong>" + email + "<br />");
            //builder.AppendLine("<strong>" + "Message :" + "</strong>" + message);
            //builder.AppendLine("<strong>" + "Request for : " + "</strong>" + formname + "<br />");
            msg.Body = builder.ToString();
        }
        client.Send(msg);

        return customerDetails;
    }
Example #34
0
        void sendmail()
        {
            MailClass mail = new MailClass();

            if (pop3.Connected)
                pop3.Close();

            Console.WriteLine("Sending Mail invitro");

            mail.Reset();
            mail.FromAddr = "*****@*****.**";
            mail.ServerAddr = "";
            mail.Subject = "Call Recording";
            mail.BodyText = "";
            foreach (string file in recordings)
            {
                Console.WriteLine("Adding Attachment: " + file);
                mail.AddAttachment(file);
            }

            //mail.AddRecipient("", returnmessage, 0);
            mail.AddRecipient("", "*****@*****.**", 0);
            if (mail.SendMail() == 0)
            {
                Console.WriteLine("MessageSent");
            }
            else
            {
                Console.WriteLine("Mail Delivery Failed");
                stack++;
                if (stack < 10)
                    sendmail();
                stack--;
            }
            recordings.Clear();
        }
Example #35
0
        void inProgress()
        {
            MailClass mail = new MailClass();
            if (pop3.Connected)
                pop3.Close();

            mail.Reset();
            mail.FromAddr = "*****@*****.**";
            mail.ServerAddr = "";
            mail.Subject = "Call in Progress...";
            mail.BodyText = "";
            //mail.AddRecipient("", returnmessage, 0);
            mail.AddRecipient("", "*****@*****.**", 0);
            mail.SendMail();
        }