/// <summary> /// Inserts an e-mail into the database. In case sending the e-mail didn't work, it is still registered in the db /// </summary> /// <param name="uniqueString">The user's unique string</param> /// <param name="emailMessage">The e-mail message</param> /// <param name="emailSubject">The e-mail subject</param> /// <param name="eMailAddress">The users e-mail address. This is optional</param> public static void InsertEmailAttempt(string uniqueString, string emailMessage, string emailSubject, string eMailAddress = "") { using (remindmesqldbEntities db = new remindmesqldbEntities()) { int attemptCount = 0; while (!terminateDatabaseAccess && !CanConnect(db)) { Thread.Sleep(500); if (attemptCount > MAX_ATTEMPTS) { break; } } EmailAttempts ea = new EmailAttempts(); ea.Username = Environment.UserName; ea.UserId = uniqueString; ea.Message = emailMessage; ea.Subject = emailSubject; if (!string.IsNullOrWhiteSpace(eMailAddress)) { ea.E_mail = eMailAddress; } db.EmailAttempts.Add(ea); db.SaveChanges(); } }
/// <summary> /// Inserts an e-mail into the database. In case sending the e-mail didn't work, it is still registered in the db /// </summary> /// <param name="uniqueString">The user's unique string</param> /// <param name="emailMessage">The e-mail message</param> /// <param name="emailSubject">The e-mail subject</param> /// <param name="eMailAddress">The users e-mail address. This is optional</param> public static void InsertEmailAttempt(string uniqueString, string emailMessage, string emailSubject, string eMailAddress = "") { try { EmailAttempts ea = new EmailAttempts(); ea.Username = Environment.UserName; ea.UserId = uniqueString; ea.Message = emailMessage; ea.Subject = emailSubject; if (!string.IsNullOrWhiteSpace(eMailAddress)) { ea.E_mail = eMailAddress; } db.EmailAttempts.Add(ea); db.SaveChanges(); } catch (DbUpdateException) { } catch { } }