public static void SendEmailTo(List<Model.UserInfo> userList, MailModel mm) { Model.UserInfo[] listUserEmail = userList.ToArray(); string[] arrUserEmail = new string[listUserEmail.Length]; for (int i = 0; i < listUserEmail.Length; i++) { arrUserEmail[i] = listUserEmail[i].UserEmail; } mm.MailTo = arrUserEmail; smtp = new SMTP(mm); smtp.Send(); }
public static void SendEmailToUseCarUsers(List<string> Email, MailModel mm) { string[] listUserEmail = Email.ToArray(); mm.MailTo = listUserEmail; mm.MailFrom = ConfigurationManager.AppSettings["commomEmail"].ToString(); mm.Password = ConfigurationManager.AppSettings["emailPassword"].ToString(); mm.SmtpServer = ConfigurationManager.AppSettings["smtpServer"].ToString(); mm.SmtpPort = int.Parse(ConfigurationManager.AppSettings["port"].ToString()); mm.UserName = ConfigurationManager.AppSettings["userName"].ToString(); mm.MailBcc = null; mm.MailCc = null; mm.SmtpPort = 25; mm.SmtpSsl = false; smtp = new SMTP(mm); smtp.Send(); }
public static void SendEmailToUseCarUsers(List <string> Email, MailModel mm) { string[] listUserEmail = Email.ToArray(); mm.MailTo = listUserEmail; mm.MailFrom = ConfigurationManager.AppSettings["commomEmail"].ToString(); mm.Password = ConfigurationManager.AppSettings["emailPassword"].ToString(); mm.SmtpServer = ConfigurationManager.AppSettings["smtpServer"].ToString(); mm.SmtpPort = int.Parse(ConfigurationManager.AppSettings["port"].ToString()); mm.UserName = ConfigurationManager.AppSettings["userName"].ToString(); mm.MailBcc = null; mm.MailCc = null; mm.SmtpPort = 25; mm.SmtpSsl = false; smtp = new SMTP(mm); smtp.Send(); }
public static void SendEmailToUseCarUsers(List<YunShanOA.Model.UseCarModel.usecaranduser> users, MailModel mm) { usecaranduser[] listUserEmail = users.ToArray(); string[] arrUserEmail = new string[listUserEmail.Length]; for (int i = 0; i < listUserEmail.Length; i++) { arrUserEmail[i] = listUserEmail[i].Email; } mm.MailTo = arrUserEmail; mm.MailFrom = ConfigurationManager.AppSettings["commomEmail"].ToString(); mm.Password = ConfigurationManager.AppSettings["emailPassword"].ToString(); mm.SmtpServer = ConfigurationManager.AppSettings["smtpServer"].ToString(); mm.SmtpPort = int.Parse(ConfigurationManager.AppSettings["port"].ToString()); mm.UserName = ConfigurationManager.AppSettings["userName"].ToString(); mm.MailBcc = null; mm.MailCc = null; mm.SmtpPort = 25; mm.SmtpSsl = false; smtp = new SMTP(mm); smtp.Send(); }
protected void btnCommit_Click(object sender, EventArgs e) { Model.Log log = new Model.Log(); int meetingApplyFormID = int.Parse(this.hfdMeetingApplyFormID.Value); Model.Meeting meeting = BusinessLogic.Meeting.GetApplyMeetingInfoByMeeingID(meetingApplyFormID); meeting.MeetingApplyFormID = meetingApplyFormID; meeting.WFID = BusinessLogic.Meeting.GetGuidByApplyForm(meetingApplyFormID); if (rbtAgree.Checked) { //同意 meeting.MeetingStatus = 4; //todo 发送邮件给与会者 MailModel mailModel = new MailModel(); Model.Meeting me = BusinessLogic.Meeting.GetApplyMeetingInfoByMeeingID(meetingApplyFormID); List<Model.UserInfo> UserEmailAndName = BusinessLogic.MeetingUser.GetUserEmailAndNameByMeetingApplyFormID(meetingApplyFormID); #region E-Mail Body System.Text.StringBuilder sbMailBody = new System.Text.StringBuilder(); sbMailBody.Append("您好!"); sbMailBody.Append(""); sbMailBody.Append("邀请您参加"); sbMailBody.Append(meeting.BeginTime); sbMailBody.Append("到"); sbMailBody.Append(meeting.EndTime); sbMailBody.Append(",在"); sbMailBody.Append(BusinessLogic.MeetingRoom.GetMeetingRoomNameByMeetingApplyFormID(meetingApplyFormID)); sbMailBody.Append("召开的会议。谢谢!如有事情耽搁,请与"); sbMailBody.Append(BusinessLogic.MeetingUser.GetUserEmailAndNameByMeetingApplyFormID(meetingApplyFormID).ToArray()[0].UserEmail); sbMailBody.Append("这个Email联系。"); #endregion mailModel.MailFrom = ConfigurationManager.AppSettings["commomEmail"].ToString(); mailModel.Password = ConfigurationManager.AppSettings["emailPassword"].ToString(); mailModel.SmtpServer = ConfigurationManager.AppSettings["smtpServer"].ToString(); mailModel.SmtpPort = int.Parse(ConfigurationManager.AppSettings["port"].ToString()); mailModel.DisplayName = "会议邀请"; mailModel.MailBcc = null; mailModel.MailCc = null; mailModel.MailSubject = meeting.MeetingTopic; mailModel.MailBody = sbMailBody.ToString(); mailModel.MailTo = null;//此处留空,在SendEmail里才会赋值 mailModel.SmtpPort = 25; mailModel.SmtpSsl = false; mailModel.UserName = ConfigurationManager.AppSettings["userName"].ToString(); try { SendEmail.SendEmailTo(UserEmailAndName, mailModel); lblMessage.Text = "会议设备安排成功!"; } catch (YunShanOA.Common.SendMailFailExecpion sendMailFail) { log = new Model.Log(); log.LogContext = sendMailFail.Message; log.LogTime = System.DateTime.Now; log.userName = Page.User.Identity.Name; log.LogTypeID = "1"; BusinessLogic.Log.SaveLog(log); lblMessage.Text = "发送邮件出现异常,请联系申请人重新申请!申请人Email:"+BusinessLogic.MeetingUser.GetUserEmailByUserName(log.userName); } } else { //不同意 meeting.MeetingStatus = 3; Dictionary<int, int> meetingIDAndName = BusinessLogic.MeetingEquipment.GetMeetingEquipmentIDAndCount(meetingApplyFormID); foreach (var m in meetingIDAndName) { BusinessLogic.MeetingEquipment.ReturnEquipmentCount(m.Key, m.Value); } } //todo 更新MeetingAndRoom里的状态,有待测试 lblMessage.Text = "会议设备处理成功"; //更新MeetingAndRoom表里的状态 BusinessLogic.MeetingRoom.UpdateMeetingAndRoomStatus(meetingApplyFormID, meeting.MeetingStatus); BusinessLogic.Meeting.UpdateMeetingApplyFormStatus(meetingApplyFormID, meeting.MeetingStatus); Server.Transfer("~/OfficeAdmin/ProcessMeetingEquipmentArr.aspx"); }
public SMTP(MailModel mailModel) { MailObject = new MailMessage(); mMailFrom = mailModel.MailFrom; mMailDisplyName = mailModel.DisplayName; mMailTo = mailModel.MailTo; mMailCc = mailModel.MailCc; mMailBcc = mailModel.MailBcc; mMailSubject = mailModel.MailSubject; mMailBody = mailModel.MailBody; mMailAttachments = mailModel.Attachments; mSMTPServer = mailModel.SmtpServer; mSMTPPort = mailModel.SmtpPort; mSMTPUsername = mailModel.UserName; mSMTPPassword = mailModel.Password; mSMTPSSL = mailModel.SmtpSsl; }
public static void SendEmailToUseCarUsers(List <YunShanOA.Model.UseCarModel.usecaranduser> users, MailModel mm) { usecaranduser[] listUserEmail = users.ToArray(); string[] arrUserEmail = new string[listUserEmail.Length]; for (int i = 0; i < listUserEmail.Length; i++) { arrUserEmail[i] = listUserEmail[i].Email; } mm.MailTo = arrUserEmail; mm.MailFrom = ConfigurationManager.AppSettings["commomEmail"].ToString(); mm.Password = ConfigurationManager.AppSettings["emailPassword"].ToString(); mm.SmtpServer = ConfigurationManager.AppSettings["smtpServer"].ToString(); mm.SmtpPort = int.Parse(ConfigurationManager.AppSettings["port"].ToString()); mm.UserName = ConfigurationManager.AppSettings["userName"].ToString(); mm.MailBcc = null; mm.MailCc = null; mm.SmtpPort = 25; mm.SmtpSsl = false; smtp = new SMTP(mm); smtp.Send(); }