public ActionResult ForgetPwd(string account, string email) { var acc = db.member.Where(m => m.member_account == account).FirstOrDefault(); if (acc != null) { if (acc.member_account == account && acc.member_profile.email == email) { var callbackUrl = Url.Action("ResetPwd", "Home", new { id = acc.member_id }, protocol: Request.Url.Scheme); GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{acc.member_profile.email}"; gs.subject = "忘記密碼"; gs.messageBody = "如果要重置您的密碼<br><br><a href=" + callbackUrl + ">請點此連結</a><br><br>如果您沒有要重置密碼,請忽略此消息。"; gs.IsHtml = true; gs.Send(); return(RedirectToAction("ForgetView", "Home", new { account = acc.member_account })); } } ViewBag.PwdErr = "您輸入的帳號或信箱錯誤"; return(View()); }
public ActionResult Edit(int id, string admin_email) { var admin = db.admin.Find(id); if (ModelState.IsValid) { admin.admin_email = admin_email; admin.emailConfirmed = false; var callbackUrl = Url.Action("Confirm", "Admin", new { account = admin.admin_account }, protocol: Request.Url.Scheme); GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{admin.admin_email}"; gs.subject = "旅途貓驗證"; gs.messageBody = "恭喜註冊成功<br><a href=" + callbackUrl + ">請點此連結</a>"; gs.IsHtml = true; gs.Send(); db.Entry(admin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
private void buttonX3_Click(object sender, EventArgs e) { try { OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MedLab_DataBase.mdb"); string cnp = rez_cnp.Text; //create the command object and store the sql query OleDbCommand aCommand = new OleDbCommand("SELECT * FROM Pacienti WHERE Cnp=@cnp", aConnection); aCommand.Parameters.Add("@cnp", OleDbType.VarChar, 100, "Cnp").Value = cnp; OleDbDataReader myreader; aConnection.Open(); myreader = aCommand.ExecuteReader(CommandBehavior.CloseConnection); myreader.Read(); string email = myreader.GetString(3); Console.WriteLine("aici"); GmailSender.SendMail("*****@*****.**", "andreia90", email, "MedLab", "Acestea sunt rezultatele analizelor."); } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }
public ActionResult Editemail(string id, string newemail) { member_profile member = db.member_profile.Find(id); if (ModelState.IsValid) { member.email = newemail; member.emailConfirmed = false; var callbackUrl = Url.Action("Confirm", "web_Member_Index", new { account = member.member_id }, protocol: Request.Url.Scheme); GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{member.email}"; gs.subject = "更改信箱"; gs.messageBody = "更改完成,點選連結驗證您的信箱<br><a href=" + callbackUrl + ">請點此連結</a>"; gs.IsHtml = true; gs.Send(); db.Entry(member).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "web_Member_Index", new { id = member.member_id })); } return(View(member)); }
public ActionResult Create([Bind(Include = "admin_id,admin_account,admin_password,admin_email,emailConfirmed")] admin admin) { if (ModelState.IsValid) { byte[] password = System.Text.Encoding.UTF8.GetBytes(admin.admin_password); byte[] hash = new System.Security.Cryptography.SHA256Managed().ComputeHash(password); string hashpassword = Convert.ToBase64String(hash); admin.admin_password = hashpassword; admin.emailConfirmed = false; var callbackUrl = Url.Action("Confirm", "Admin", new { account = admin.admin_account }, protocol: Request.Url.Scheme); GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{admin.admin_email}"; gs.subject = "旅途貓驗證"; gs.messageBody = "恭喜註冊成功<br><a href=" + callbackUrl + ">請點此連結</a>"; gs.IsHtml = true; gs.Send(); db.admin.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Edit([Bind(Include = "member_id,member_account,member_password,member_status")] member member) { string email = db.member_profile.Where(m => m.member_id == member.member_id).FirstOrDefault().email; if (member.member_status == true) { GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{email}"; gs.subject = "會員通知"; gs.messageBody = "<h3>親愛的會員您好:</h3><br /><p>因您已違反本網站規定,本站將取消您的會員,如有任何疑問請與本站客服人員聯絡。</p>"; gs.IsHtml = true; gs.Send(); } if (ModelState.IsValid) { db.Entry(member).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(member)); }
public HomeController(ApplicationDbContext db, IHttpContextAccessor accessor, ZillowRentEstimate zillowRentEstimate, GmailSender gmailSender) { _db = db; _accessor = accessor; _zillowRentEstimate = zillowRentEstimate; _gmailSender = gmailSender; }
public ActionResult Edit([Bind(Include = "id,member_id,admin_id,issue_id,report_date,issue_content,issue_result,issue_status,resolve_date,problem_id")] issue issue) { string email = db.member_profile.Where(m => m.member_id == issue.member_id).FirstOrDefault().email; string result = issue.issue_result; string content = issue.issue_content; int id = issue.issue_id; string controller; switch (id) { case 1: controller = "issues"; break; case 2: controller = "members"; break; case 3: controller = "comments"; break; case 4: controller = "messages"; break; default: controller = "issues"; break; } if (issue.issue_status == true) { GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{email}"; gs.subject = "系統問題回覆"; gs.messageBody = "<div><h3>關於您的問題:</h3><p>" + content + "</p><br></div>" + "<div><h3>以下是本網站針對此問題做出的回覆:</h3><p>" + result + "</p></div><br><footer>感謝您寶貴的建議,全體人員在此感謝。</footer>"; gs.IsHtml = true; gs.Send(); } issue.resolve_date = DateTime.Now; if (ModelState.IsValid) { db.Entry(issue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToRoute(new { controller = controller, action = "Index", tab = 2 })); } ViewBag.admin_id = new SelectList(db.admin, "admin_id", "admin_account", issue.admin_id); return(View(issue)); }
public ActionResult Index(member model, HttpPostedFileBase photo) { string mem_id = db.Database.SqlQuery <string>("Select dbo.GetmemberId()").FirstOrDefault(); model.member_id = mem_id; model.member_profile.member_id = mem_id; model.member_profile.member_score = 0; model.member_profile.create_time = DateTime.Now; model.member_profile.emailConfirmed = false; byte[] password = System.Text.Encoding.UTF8.GetBytes(model.member_password); byte[] hash = new System.Security.Cryptography.SHA256Managed().ComputeHash(password); string hashpassword = Convert.ToBase64String(hash); model.member_password = hashpassword; string fileName = ""; if (photo != null) { if (photo.ContentLength > 0) { string t = photo.FileName; fileName = mem_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + Path.GetExtension(t); photo.SaveAs(Server.MapPath("~/images/member/" + fileName)); model.member_profile.profile_photo = fileName; } } var callbackUrl = Url.Action("Confirm", "Register", new { account = model.member_account, id = mem_id }, protocol: Request.Url.Scheme); if (ModelState.IsValid) { GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; gs.password = "******"; gs.sender = "旅途貓 <*****@*****.**>"; gs.receiver = $"{model.member_profile.email}"; gs.subject = "旅途貓驗證"; gs.messageBody = "恭喜註冊成功<br><a href=" + callbackUrl + ">請點此連結</a>"; gs.IsHtml = true; gs.Send(); db.member.Add(model); db.member_profile.Add(model.member_profile); db.SaveChanges(); return(RedirectToAction("ConfirmView", "Register", new { account = model.member_account })); } return(View(model)); }
public void SetUp() { smtpClientWrapper = new Mock <ISmtpClientWrapper>(); fixture = new Fixture(); zapotrzebowanie = fixture.Build <tblZapotrzebowanie>() .Without(w => w.tblUrzadzenia) .Without(w => w.tblZapotrzebowaniePozycje) .Without(w => w.tblZapotrzebowanieStatus) .Without(w => w.tblPliki) .With(w => w.tblKlasyfikacjaOgolna, fixture.Build <tblKlasyfikacjaOgolna>() .Without(x => x.tblZapotrzebowanie).Create()) .With(w => w.tblKlasyfikacjaSzczegolowa, fixture.Build <tblKlasyfikacjaSzczegolowa>() .Without(x => x.tblZapotrzebowanie).Create()) .With(w => w.tblKontrahent, fixture.Build <tblKontrahent>() .Without(x => x.tblRuchNaglowek) .Without(x => x.tblZamowienieHandlowe) .Without(x => x.tblZamowienieHandlowe1) .Without(x => x.tblZapotrzebowanie) .Create()) .With(w => w.PracownikOdpZaZakup, fixture.Build <tblPracownikGAT>() .Without(x => x.tblZapotrzebowanie) .Without(x => x.tblRuchNaglowek) .Without(x => x.tblWynikiBadanGeowloknin) .Without(x => x.tblZamowienieHandlowe) .Create()) .With(w => w.tblPracownikGAT, fixture.Build <tblPracownikGAT>() .Without(x => x.tblZapotrzebowanie) .Without(x => x.tblRuchNaglowek) .Without(x => x.tblWynikiBadanGeowloknin) .Without(x => x.tblZamowienieHandlowe) .Create()) .Create(); mailMessage = new ZapotrzebowanieMailMessage(zapotrzebowanie, new MailAddressesFromTo() { gmailAddressFrom = gmailAddresFrom, mailAddressesTo = new List <string> { "*****@*****.**" } }); sut = CreateSut(smtpClientWrapper.Object); }
public ActionResult ForgotPassword(ForgotPasswordViewModel model) { if (!string.IsNullOrEmpty(model.Email)) { var ASPUser = UserManager.FindByName(model.Email); //bool confirm = UserManager.IsEmailConfirmed(user.Id); //if (user == null || !confirm) //{ // // Don't reveal that the user does not exist or is not confirmed // return View("ForgotPasswordConfirmation"); //} var user = db.Users.Where(c => c.Email == model.Email).FirstOrDefault(); if (user == null || ASPUser == null) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = UserManager.GeneratePasswordResetToken(ASPUser.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); ForgotPasswordDTO forgotPasswordDTO = new ForgotPasswordDTO() { FName = user.FName, LName = user.LName, MName = user.MName, callbackUrl = callbackUrl }; EmailTemplate Email = new EmailTemplate(); string path = @"~/Common/ForgotPasswordEmailTemplate.html"; var emailHtml = Email.ReadTemplateEmail(forgotPasswordDTO, path); GmailSender.SendEmail("*****@*****.**", "Serious!1", new List <string>() { model.Email }, "Reset Password", emailHtml, null); UserManager.SendEmailAsync(ASPUser.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Tries to send the export e-mail on a separate thread. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArguments">The event arguments.</param> private void DoSendExportEmailWork(object sender, DoWorkEventArgs eventArguments) { SentEmail = true; List <string> outputFileNames = new List <string>(); bool createdFiles = _mainModel.ExportFiles(OutputDirectory, SendBooksReadFile, SendLocationsFile, outputFileNames, out _mailboxErrorMessage); if (!createdFiles) { return; } GmailSender mailSender = new GmailSender(); mailSender.MessageText = EmailMessageText; mailSender.SourceEmail = HomeEmailAdress; mailSender.SourcePassword = Password; mailSender.DestinationEmail = DestinationEmailAddress; SentEmail = mailSender.SendEmail(outputFileNames, out _mailboxErrorMessage); }
public ActionResult pwdEdit(string id, string oldPwd, string mbrPwd) { if (Session["memberID"] == null) { return(RedirectToAction("Login", "Login")); } string tempPwd = ""; var account = db.MemberAccount.Find(id); var member = db.Member.Find(id); tempPwd = account.mbrPwd; if (tempPwd == oldPwd) { account.mbrPwd = mbrPwd; if (ModelState.IsValid) { db.SaveChanges(); GmailSender gs = new GmailSender(); gs.account = "*****@*****.**"; //帳號 gs.password = "******"; //應用程式密碼 gs.sender = "*****@*****.**"; //寄件人mail gs.receiver = $"{member.mbrMail}"; //收件人mail 用到變數時前面加$ gs.subject = "密碼更改通知"; //標題 gs.messageBody = $"<html><body>{member.mbrName}您好:<br />您的密碼已做更改,若您沒有近期沒有更改密碼,請盡速與我們聯繫。</body></html>"; //內容 gs.IsHtml = true; //內容是否使用html gs.Send(); return(RedirectToAction("mbrIndex")); } } ViewBag.error = "舊密碼不符"; ViewBag.id = Session["memberID"].ToString(); return(View()); }
public async Task SendMessage_SprawdzaCzyRZeczywiscieWysylaMaila() { sut = CreateSut(new SmtpClientWrapper()); await sut.SendMessageAsync(mailMessage.Create()); }
private void buttonX3_Click(object sender, EventArgs e) { string email = textBox5.Text; GmailSender.SendMail("*****@*****.**", "andreia90", email, "MedLab", "Acestea sunt rezultatele analizelor."); }
private void buttonX3_Click(object sender, EventArgs e) { string email = textBox5.Text; GmailSender.SendMail("*****@*****.**", "Laurentiu", email, "MedLab", "Acestea sunt rezultatele analizelor."); }
protected void emailogin(Network n, Irc.IrcEventArgs e) { string name = ""; if (IsMatch("^emailauth (?<name>.*?)$", e.Data.Message.Substring(BOT_CONTROL_SEQ.Length))) { name = (Matches["name"].Value.Length > 16) ? Matches["name"].Value.Substring(0, 16) : Matches["name"].Value; } else { name = e.Data.Nick; } System.Data.DataTable accounts; String query = "SELECT id \"ID\", name \"NAME\", email \"EMAIL\", gpgkey \"key\" FROM accounts;"; accounts = db.GetDataTable(query); int id = 0; bool noemail = true; foreach (DataRow account in accounts.Rows) { id++; if (account["NAME"] as string == name && account["EMAIL"].ToString().Length > 0) { Answer(n, e, FormatItalic(e.Data.Nick + ": .. sending #email, please be patient..")); gpg.Recipient = account["key"] as string; MemoryStream unencrypted = new MemoryStream(Encoding.ASCII.GetBytes(name + ":" + DateTime.Now.Ticks + "\n")); MemoryStream encrypted = new MemoryStream(); gpg.Encrypt(unencrypted, encrypted); Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("verify", StreamToString(unencrypted)); db.Update("accounts", data, String.Format("id = {0}", id)); GmailSender g = new GmailSender("*****@*****.**", "LAcIYB<4;=~zAbW{}7Tdjk,kW!Nq.~-C"); g.Send("*****@*****.**", account["EMAIL"].ToString(), "#bitcoin-police gpg login request for: " + name, StreamToString(encrypted)); Answer(n, e, e.Data.Nick + ": An Email has been sent to your registered email address. Decrypt the contents using your GpG Key and then send IRC message " + FormatBold("#everify <decodedctext>") + " to login."); noemail = false; } } if (noemail) { Answer(n, e, e.Data.Nick + ": No registered email for your nick. To register an email; login normally then issue IRC command " + FormatBold("#setemail <emailaddress>")); Answer(n, e, FormatBold("Once you have registered an email address, you may perform a two-factor login at any time by typing #email")); } }
protected void setemail(Network n, Irc.IrcEventArgs e) { if (Bot.isLoggedIn(e.Data.Nick)) { string name = ""; if (IsMatch("^setemail (?<email>.*?)$", e.Data.Message.Substring(BOT_CONTROL_SEQ.Length))) { if ((Matches["email"].Value.IndexOf("@") > 1)) { name = e.Data.Nick; System.Data.DataTable accounts; String query = "SELECT id \"ID\", name \"NAME\", email \"EMAIL\", gpgkey \"key\" FROM accounts;"; accounts = db.GetDataTable(query); foreach (DataRow account in accounts.Rows) { if (account["NAME"] as string == name) { Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("email", Matches["email"].Value); db.Update("accounts", data, String.Format("id = {0}", account["ID"])); GmailSender g = new GmailSender("*****@*****.**", "LAcIYB<4;=~zAbW{}7Tdjk,kW!Nq.~-C"); g.Send("*****@*****.**", Matches["email"].Value, "#bitcoin-police email confirmation for: " + name, "Confirming your email address."); Answer(n, e, e.Data.Nick + ": Your email address has been registered. An Email has been sent to your registered email address."); } } } else { Answer(n, e, e.Data.Nick + ": INVALID EMAIL ADDRESS!"); } } } else { AnswerWithNotice(n, e, FormatBold(String.Format("You may only set the email for your user if you are logged in. Command Usage: {0}setemail <email>", BOT_CONTROL_SEQ))); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var UserAddresses = new List <UserAddress>() { new UserAddress() { IsDeleted = false, Address = new Address() { IsDeleted = false, City = model.City, Zip = model.Zip, State = model.State, MainAddress = model.MainAddress, DeliveryAddress = model.DeliveryAddress, Country = model.Country } } }; var user = new data.Entities.User() { Email = model.Email, FName = model.FName, LName = model.LName, Individually = model.Individually, IsDeleted = false, MName = model.MName, NationalId = model.NationalId, Phone = model.Phone, UserAddresses = UserAddresses, }; var corporateDetails = new CorporateDetails(); if (model.Individually == 2) { corporateDetails = new CorporateDetails() { CorporateName = model.CorporateName, CorporateSite = model.CorporateSite, RegistrationNo = model.RegistrationNo, user = user }; db.CorporatesDetails.Add(corporateDetails); db.SaveChanges(); } else { db.SaveChanges(); } var ASPUser = new ApplicationUser { user = user, UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(ASPUser, model.Password); if (result.Succeeded) { UserManager.AddToRole(ASPUser.Id, "User"); await SignInManager.SignInAsync(ASPUser, isPersistent : false, rememberBrowser : false); EmailTemplate Email = new EmailTemplate(); string path = @"~/Common/WelcomeEmailTemplate.html"; var emailHtml = Email.ReadTemplateEmail(user, path); try { GmailSender.SendEmail("*****@*****.**", "Serious!1", new List <string>() { model.Email }, "Welcome", emailHtml, null); } catch (Exception e) { db.CorporatesDetails.Remove(corporateDetails); var logins = ASPUser.Logins; var rolesForUser = await _userManager.GetRolesAsync(ASPUser.Id); using (var transaction = context.Database.BeginTransaction()) { foreach (var login in logins.ToList()) { await _userManager.RemoveLoginAsync(login.UserId, new UserLoginInfo(login.LoginProvider, login.ProviderKey)); } if (rolesForUser.Count() > 0) { foreach (var item in rolesForUser.ToList()) { await _userManager.RemoveFromRoleAsync(ASPUser.Id, item); } } await _userManager.DeleteAsync(ASPUser); transaction.Commit(); } db.SaveChanges(); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <Dictionary <Profile, List <ProfileAlert> > > SendWeeklyReviewsAsync(Subplatform subplatform) { // Get all profiles with at least 1 read profilealert from last week List <Profile> allProfiles = GetProfiles() .Where(p => p.Settings.Find(us => us.SettingName.Equals(Setting.Account.WANTS_WEEKLY_REVIEW_VIA_MAIL)).boolValue&& p.Subscriptions.Count > 0 && p.Email != null && p.ProfileAlerts.FindAll(pa => pa.TimeStamp.Date >= DateTime.Today.AddDays(-7)).Count > 0) .ToList(); // Pick 1 random alert from each day Dictionary <Profile, List <ProfileAlert> > AlertsPerProfile = new Dictionary <Profile, List <ProfileAlert> >(); Random random = new Random(); allProfiles.ForEach(p => { Dictionary <DateTime, List <ProfileAlert> > profileAlertsByDate = p.ProfileAlerts .Where(pa => pa.Alert.Item.SubPlatforms.Contains(subplatform)) .GroupBy(pa => pa.TimeStamp.Date).ToDictionary(kv => kv.Key, kv => kv.ToList()); List <ProfileAlert> profileAlerts = new List <ProfileAlert>(); if (profileAlertsByDate.Count == 0) { return; } profileAlertsByDate.Values.ToList().ForEach(v => { if (v.Count > 0) { profileAlerts.Add(v[random.Next(0, v.Count)]); } }); AlertsPerProfile.Add(p, profileAlerts); }); // Make mail GmailSender sender = new GmailSender { IsHtml = true, Subject = "Weekly Review" }; await Task.Run(() => { AlertsPerProfile.Keys.ToList().ForEach(p => { // Get profileAlerts List <ProfileAlert> profileAlerts = new List <ProfileAlert>(); AlertsPerProfile.TryGetValue(p, out profileAlerts); if (profileAlerts.Count == 0) { return; } // Construct body StringBuilder sbBody = new StringBuilder(GmailSender.WeeklyReviewBody); sbBody.Replace(GmailSender.DefaultUsernameSubstring, p.UserData.FirstName ?? p.UserName); StringBuilder sb = new StringBuilder(); profileAlerts = profileAlerts.OrderByDescending(pa => pa.TimeStamp).ToList(); profileAlerts.ForEach(pa => { StringBuilder sbItem = new StringBuilder(GmailSender.WeeklyReviewListItem); sbItem.Replace(GmailSender.WeeklyReviewListItemIconSubstring, "https://integratieproject.azurewebsites.net" + pa.Alert.Item.IconURL.Substring(1) ?? GmailSender.DefaultItemIcon); sbItem.Replace(GmailSender.DefaultItemLinkSubstring, "#"); //TODO: LINKEN NAAR ITEMDETAIL PAGE sbItem.Replace(GmailSender.WeeklyReviewListItemNameSubstring, pa.Alert.Item.Name); sbItem.Replace(GmailSender.WeeklyReviewListItemDescriptionSubstring, pa.Alert.Item.Name + " " + pa.Alert.Event + " " + pa.Alert.Subject + " - " + pa.TimeStamp.Date.ToShortDateString() + "<br>" + pa.Alert.Text + "." ); sb.Append(sbItem.ToString()); }); List <Person> persons = p.Subscriptions.Where(i => i is Person).Select(i => (Person)i).ToList(); Person person = persons.First(pe => pe.Records.FindAll(r => r.Date.Date >= DateTime.Today.AddDays(-7)).Count == persons.Max(ps => ps.Records.FindAll(r => r.Date.Date >= DateTime.Today.AddDays(-7)).Count)); sbBody.Replace(GmailSender.SubplatformSubstring, subplatform.Name); sbBody.Replace(GmailSender.DefaultItemLinkSubstring, "#"); sbBody.Replace(GmailSender.WeeklyReviewListItemNameSubstring, person.Name); sbBody.Replace(GmailSender.WeeklyReviewListItemDescriptionSubstring, person.Name + " is tijdens de afgelopen week " + person.Records.FindAll(r => r.Date.Date >= DateTime.Today.AddDays(-14)).Count + " aantal keer het onderwerp geweest in iemand zijn/haar tweet."); sbBody.Replace(GmailSender.WeeklyReviewListSubstring, sb.ToString()); // Set mail body sender.Body = sbBody.ToString(); // Set mail recipient sender.ToEmail = p.Email; // Send mail sender.Send(); // Make WeeklyReview and persist if (p.WeeklyReviews == null) { p.WeeklyReviews = new List <WeeklyReview>(); } WeeklyReview weeklyReview = new WeeklyReview { TopPersonId = person.ItemId, Profile = profileAlerts[0].Profile, TimeGenerated = DateTime.Now, TopPersonText = person.Name + " is tijdens de afgelopen week " + person.Records.FindAll(r => r.Date.Date >= DateTime.Today.AddDays(-14)).Count + " aantal keer het onderwerp geweest in iemand zijn/haar tweet.", WeeklyReviewsProfileAlerts = new List <WeeklyReviewProfileAlert>() }; profileAlerts.ForEach(pa => { WeeklyReviewProfileAlert weeklyReviewProfileAlerts = new WeeklyReviewProfileAlert { ProfileAlert = pa, WeeklyReview = weeklyReview }; pa.WeeklyReviewsProfileAlerts.Add(weeklyReviewProfileAlerts); weeklyReview.WeeklyReviewsProfileAlerts.Add(weeklyReviewProfileAlerts); }); p.WeeklyReviews.Add(weeklyReview); }); // Persist changed profiles }); ProfileRepo.UpdateProfiles(allProfiles); await UowManager.SaveAsync(); return(AlertsPerProfile); }
public void SimpleSendShouldSucceed() { var g = new GmailSender(Account, Password); g.Send(Account, To, "TEST: gmail test message", "test message body"); }