public ActionResult SendEmail(Email model, HttpPostedFileBase postedFile) { TryValidateModel(model); if (ModelState.IsValid) { try { String toEmail = model.ToEmail; String subject = model.Subject; String contents = model.Contents; model.filename = postedFile.FileName; string serverPath = Server.MapPath("~/Uploads/"); model.Path = serverPath + model.filename; postedFile.SaveAs(model.Path); EmailSending es = new EmailSending(); es.Send(toEmail, subject, contents, model.filename, model.Path); ViewBag.Result = "Email has been send."; ModelState.Clear(); return(View(new Email())); } catch { return(View()); } } return(View()); }
public DashBoardController() { service = new CustomerService(); bidsService = new BidsService(); dbContext = new MyDealDbContext(); _email = new EmailSending(); }
private void btnSendCode_Click(object sender, EventArgs e) { EmailSending email = new EmailSending(); email.SendCode(txtTextEmail.Text); MessageBox.Show("Kod gonderildi"); }
private void Invia() { bool TuttoRiempito = false; try { if (eOggetto.Text.Length > 3) { if (eTesto.Text.Length > 3) { if (cbGiudizio.SelectedIndex > -1) { TuttoRiempito = true; } } } } catch { TuttoRiempito = false; } if (TuttoRiempito) { var ok = false; var r = ""; Enabled = false; try { var t = cGB.DatiUtente.Nome + " [" + cGB.DatiUtente.Email + "] :" + Environment.NewLine + eTesto.Text; using (var e = new EmailSending()) r = e.MandaMail(eOggetto.Text + " [" + cbGiudizio.Text + "]", t, "*****@*****.**"); ok = r.Equals("OK", StringComparison.OrdinalIgnoreCase); } catch (Exception ex) { cGB.MsgBox(ex.Message, MessageBoxIcon.Error); } Enabled = true; if (ok) { cGB.MsgBox("Inviato !", MessageBoxIcon.Information); ChiudiScheda(); } else { cGB.MsgBox(r, MessageBoxIcon.Exclamation); } } else { cGB.MsgBox("Si prega di riempire tutti i campi!", MessageBoxIcon.Exclamation); } }
public IActionResult Signin(String name, string msg, string email) { EmailSending obj = new EmailSending(); obj.SendEmail(email, msg, "Demo"); return(View()); }
public void MessageSend_StringIsNullOrEmpty_ExpectedException(string from, string to, string subject, string message) { // Act EmailSending email = new EmailSending(); var actual = email.MessageSend(from, to, subject, message); // Assert Assert.ThrowsException <NullReferenceException>(() => email.MessageSend(from, to, subject, message)); }
private bool MandaDBSulSito__(string yyyyMMddHHmmss) { var ok = false; cGB.MsgI("Sincronizzazione in corso..."); try { using (var c = new EmailSending()) { //NON FATE I CAZZONI ! IO IL SITO LO PAGO E IL SERVIZIO LO OFFRO GRATUITAMENTE var resu = c.ControllaCredenzialiRC(Credenziali); switch (resu) { case CredenzialiRisultato.Assente: if (cGB.MsgBox("Il nome utente non è presente nell'archivio! Vuoi crearlo?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (c.CreaDBPerRC(Credenziali)) { var tyy = "Adesso puoi accedere ai tuoi dati direttamente dal cellulare da questa pagina http://www.maionemiky.it/mLogin.aspx con le seguenti credenziali:"; tyy += Environment.NewLine + "Utente: " + Email; tyy += Environment.NewLine + "Password: "******"RationesCurare7", tyy, Email); ok = MandaDBSulSito(yyyyMMddHHmmss); } else { cGB.MsgBox("Non sono riuscito a creare il nuovo utente! Riprovare!", MessageBoxIcon.Exclamation); return(false); } } break; case CredenzialiRisultato.Errore: cGB.MsgBox("Non riesco a collegarmi al sito!", MessageBoxIcon.Exclamation); break; case CredenzialiRisultato.TuttoOK: ok = MandaIlFile(yyyyMMddHHmmss); break; case CredenzialiRisultato.Presente_PasswordErrata: cGB.MsgBox("Nome utente o password non validi!", MessageBoxIcon.Exclamation); break; } } } catch (Exception ex) { cGB.MsgBox(ex.Message, MessageBoxIcon.Hand); } return(ok); }
public string PostOrder(List <OrdersDto> orders) { ORDR_MGMT_SYSEntities entities = new ORDR_MGMT_SYSEntities(); string status = ""; var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; var usr_id = identity.Claims.Where(c => c.Type == ClaimTypes.Sid) .Select(c => c.Value) .SingleOrDefault(); var email = identity.Claims.Where(c => c.Type == ClaimTypes.Email) .Select(c => c.Value) .SingleOrDefault(); System.Data.Entity.Core.Objects.ObjectParameter document_id = new System.Data.Entity.Core.Objects.ObjectParameter("RETURN_SERIES", typeof(string)); entities.GenerateDocketSeries("ORDERS", DateTime.Now.Year.ToString(), document_id); if (document_id == null || document_id.Value.ToString() == "") { return("Docket series not found"); } try { foreach (OrdersDto dto in orders) { DateTime orderedDateTime; DateTime.TryParseExact(dto.ORDERED_DATE, "dd-MM-yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out orderedDateTime); entities.USR_ORDERS.Add(new USR_ORDERS { ORD_ID = document_id.Value.ToString(), PRD_ID = dto.PRD_ID, ORD_LINE_NUM = dto.LineNum, PRD_QNTY = dto.PRD_QNTY, TAX_AMT = dto.TAX_AMT, NET_AMT = dto.NET_AMT, GROSS_AMT = dto.GROSS_AMT, DISC_AMT = dto.DISC_AMT, ORDRED_DATE = orderedDateTime, ORDER_STATUS = dto.ORDER_STATUS, CREATED_BY = usr_id, CUSTOMER_ID = usr_id, CREATED_ON = DateTime.Now }); } entities.SaveChanges(); status = "Inserted Successfully. "; EmailSending sending = new EmailSending(); status += sending.SendMail(email, "Your has been placed", usr_id); } catch (Exception ex) { status = ex.Message; } return(status); }
/// <summary> /// The method gets the updated email from PL and save it in DB /// </summary> /// <param name="item">The updated email</param> public void UpdateElement(EmailSendingDTO element) { EmailSending email = new EmailSending { Email = element.Email }; uow.EmailSendings.Update(email); uow.SaveChanges(); }
public void EmailIsValid_Returnfalse() { // Arrange string mail = "kristy_92inbox.ru"; // Act EmailSending emailSending = new EmailSending(); var actual = emailSending.EmailIsValid(mail); //Assert Assert.IsFalse(actual); }
private void sendMailToUser(string email, string name, string id) { EmailSending es = new EmailSending(); StringBuilder sbEmailBody = new StringBuilder(); sbEmailBody.Append("Dear " + name + ",<br/><br/>"); sbEmailBody.Append("Please click on the following link to reset your password"); sbEmailBody.Append("<br/>"); sbEmailBody.Append("http://localhost:22460/RegisterLogin/ChangePassword.aspx?id=" + id); sbEmailBody.Append("<br/><br/>"); sbEmailBody.Append("<b>Official Youpaper</b>"); string subject = "Reset Your Password"; es.sendEMail(email, sbEmailBody.ToString(), subject); }
private void sendVerificationMail(string email, string name, string r) { EmailSending es = new EmailSending(); StringBuilder sbEmailBody = new StringBuilder(); sbEmailBody.Append("Dear " + name + ",<br/><br/>"); sbEmailBody.Append("Please click on the following link to verify your account"); sbEmailBody.Append("<br/>"); sbEmailBody.Append("http://localhost:22460/RegisterLogin/UserVerification.aspx?token=" + r + "&uemail=" + email); sbEmailBody.Append("<br/><br/>"); sbEmailBody.Append("<b>Official Youpaper</b>"); string subject = "YouPaper Registration Verification"; es.sendEMail(email, sbEmailBody.ToString(), subject); }
public void MessageSend_() { // Arrange string from = "*****@*****.**"; string to = "*****@*****.**"; string subject = "MySubject"; string message = "Hello, it's a test mail"; // Act EmailSending email = new EmailSending(); MailMessage actual = email.MessageSend(from, to, subject, message); // Assert Assert.AreEqual(from, actual.From.Address); Assert.AreEqual(to, actual.To.First().Address); Assert.AreEqual(subject, actual.Subject); Assert.AreEqual(message, actual.Body); }
private void bOK_Click(object sender, EventArgs e) { using (var ema = new EmailSending()) { var r = ema.ControllaCredenzialiRC_simple(eEmail.Text, ePassword.Text); switch (r) { case CredenzialiRisultato.TuttoOK: using (var fd = new FolderBrowserDialog { Description = "Cartella dove creare il DB dell'utente", ShowNewFolderButton = true }) if (fd.ShowDialog() == DialogResult.OK) { Psw_ = ePassword.Text; FileSelezionato_ = Path.Combine(fd.SelectedPath, eEmail.Text + ".rqd8"); var ok = cGB.ScaricaUltimoDBDalWeb(ema, "19000101000000", FileSelezionato, eEmail.Text, ePassword.Text, true); if (ok) { DialogResult = DialogResult.OK; } } break; case CredenzialiRisultato.Presente_PasswordErrata: cGB.MsgBox("Password errata!", MessageBoxIcon.Exclamation); break; case CredenzialiRisultato.Assente: cGB.MsgBox("Questo utente non esiste!", MessageBoxIcon.Exclamation); break; case CredenzialiRisultato.Errore: cGB.MsgBox("Errore, riprovare.", MessageBoxIcon.Error); break; case CredenzialiRisultato.ProgrammaNonAutorizzato: cGB.MsgBox("Programma non autorizzato!", MessageBoxIcon.Error); break; } } }
public static void RegistraUtenteSito() { try { using (var e = new EmailSending()) e.AggiornaUtente( new UtenteProgramma { Programma = "RationesCurare7", Utente = DatiDBFisico.Nome, Versione = MyProductVersion } ); } catch { //no connection } }
private void sendMailToUser(string email, string name, string query, string reply) { EmailSending es = new EmailSending(); StringBuilder sbEmailBody = new StringBuilder(); sbEmailBody.Append("Dear " + name + ",<br/><br/>"); sbEmailBody.Append("This Mail is response for your query"); sbEmailBody.Append("<br/>"); sbEmailBody.Append("<strong> ' " + query + " '</strong>"); sbEmailBody.Append("<br/>"); sbEmailBody.Append("Our Reply :"); sbEmailBody.Append("<br/>"); sbEmailBody.Append(reply); sbEmailBody.Append("<br/><br/>"); sbEmailBody.Append("<b>Official Youpaper</b>"); string subject = "YouPaper Enquiry"; es.sendEMail(email, sbEmailBody.ToString(), subject); }
public IActionResult SignIn(string name, string address, string email) { // to file // email sending code // EmailSending obj = new EmailSending(); Random rn = new Random(); int otp = rn.Next(1000); string OTP = otp.ToString(); string msg = "Your OTP =" + OTP; obj.SendEmail(email, msg, "OTP"); return(View()); }
public static bool ControllaDBSulServer() { var ok = false; try { using (var e = new EmailSending()) { var yyyyMMddHHmmss = DatiUtente.UltimaModifica.ToString("yyyyMMddHHmmss"); var yyyyMMddHHmmss_WEB = e.VersioneDB(DatiUtente.Email, DatiUtente.Psw); var comparazione = e.ComparaDBRC(yyyyMMddHHmmss, DatiUtente.Email, DatiUtente.Psw); if (comparazione == Comparazione.Server) { using (var fdbd = new fDBDate(DatiUtente.UltimaModifica, yyyyMMddHHmmss_WEB)) if (fdbd.ShowDialog() == DialogResult.Yes) { sDB.Connessione.Close(); ok = ScaricaUltimoDBDalWeb(e, yyyyMMddHHmmss, DatiDBFisico.Path, DatiUtente.Email, DatiUtente.Psw, false); } } } } catch (Exception ex) { var erMsg = ex.Message; if (erMsg.Length > 1500) { erMsg = erMsg.Substring(0, 1500) + " [...]"; } if (MsgBox($"Errore: {erMsg}.{Environment.NewLine}Riprovo?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ok = ControllaDBSulServer(); } } return(ok); }
public bool MandaDBSulSito(string yyyyMMddHHmmss, bool Force = false) { var ok = false; if (cGB.sDB.UltimaModifica > DateTime.MinValue || Force) { using (var e = new EmailSending()) { var comparazione = e.ComparaDBRC(yyyyMMddHHmmss, Email, Psw); if (comparazione == Comparazione.Server) { if (cGB.MsgBox("Il database sul server è più aggiornato di quello locale; Vuoi sovrascrivere quello sul server?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return(false); } } } while (!ok) { cGB.CreaIcona("Sincronizzazione del DataBase"); ok = MandaDBSulSito__(yyyyMMddHHmmss); if (!ok) { if (cGB.MsgBox("Riprovo?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { break; } } } } cGB.MyNotifyIcon.Visible = false; return(ok); }
private void bRecupera_Click(object sender, EventArgs ea) { Enabled = false; try { using (EmailSending e = new EmailSending()) if (e.RecuperaPswRC_Six(PswC, Email)) { cGB.MsgBox("Ti ho inviato la password via email!"); } else { cGB.MsgBox("Invio non riuscito!", MessageBoxIcon.Exclamation); } } catch (Exception ex) { cGB.MsgBox("Errore : " + ex.Message, MessageBoxIcon.Exclamation); } Enabled = true; }
private bool MandaIlFile(string yyyyMMddHHmmss) { //TODO: [M] GB.CompattaDB(); var zs = ZippaDB(MettiDBInTempPath(PathDB)); if (UploadFile(yyyyMMddHHmmss, zs)) { using (var dez = new EmailSending()) if (dez.DeZippaDBRC(Email + ".zip")) { cGB.MsgI("Sincronizzazione completata!"); return(true); } else { cGB.MsgBox("Non sono riuscito a sincronizzare il DataBase!", MessageBoxIcon.Exclamation); return(false); } } cGB.MsgBox("Non sono riuscito a inviare il DataBase!", MessageBoxIcon.Exclamation); return(false); }
public CustomerService() { repository = new GenericRepository <Customer>(); dbcontext = new MyDealDbContext(); email = new EmailSending(); }
public static bool ScaricaUltimoDBDalWeb(EmailSending e, string yyyyMMddHHmmss, string PathDB, string email_, string psw, bool CreaNuovo) { var ok = false; var db_path = Path.GetDirectoryName(PathDB); var zip_path = Path.Combine(db_path, email_ + ".zip"); try { var db_bytes = e.OttieniUltimoDBRC(yyyyMMddHHmmss, email_, psw); if ((db_bytes?.Length ?? 0) > 0) { File.WriteAllBytes(zip_path, db_bytes); if (File.Exists(zip_path)) { var guid = Path.Combine(db_path, Guid.NewGuid().ToString()); try { if (!CreaNuovo) { File.Move(PathDB, guid); } try { var zip = new ZipFile(zip_path); foreach (ZipEntry zipEntry in zip) { if (!zipEntry.IsFile) { continue; // Ignore directories } var entryFileName = Path.GetFileName(zipEntry.Name); var buffer = new byte[4096]; // 4K is optimum var zipStream = zip.GetInputStream(zipEntry); // Manipulate the output filename here as desired. var fullZipToPath = Path.Combine(db_path, entryFileName); using (var streamWriter = File.Create(fullZipToPath)) Copy(zipStream, streamWriter, buffer); } zip.Close(); File.Delete(guid); File.Delete(zip_path); ok = true; } catch (Exception ex4) { File.Move(guid, PathDB); MsgBox(ex4); } } catch (Exception ex3) { MsgBox(ex3); } } } } catch (Exception ex2) { MsgBox(ex2); } return(ok); }
private bool UploadFile(string yyyyMMddHHmmss, string filename) { var b = false; try { var strFile = Path.GetFileName(filename); using (var srv = new EmailSending()) { var fInfo = new FileInfo(filename); var numBytes = fInfo.Length; try { using (var fStream = new FileStream(filename, FileMode.Open, FileAccess.Read)) using (var br = new BinaryReader(fStream)) { var data = br.ReadBytes(Convert.ToInt32(numBytes)); br.Close(); fStream.Close(); var R = srv.UploadFileRC_simple(yyyyMMddHHmmss, Credenziali.Utente, Credenziali.Psw, data, strFile); //var R = srv.UploadFileRC(Credenziali, data, strFile); try { switch (R.CredenzialiRisultato_) { case CredenzialiRisultato.TuttoOK: return(true); case CredenzialiRisultato.FileInviato: return(true); case CredenzialiRisultato.Presente_PasswordErrata: throw new Exception("Password errata!"); case CredenzialiRisultato.Assente: throw new Exception("DB assente!"); case CredenzialiRisultato.Errore: throw new Exception("Errore!"); case CredenzialiRisultato.ProgrammaNonAutorizzato: throw new Exception("Programma non autorizzato!"); case CredenzialiRisultato.DBSulServerEPiuRecente: throw new Exception("DB sul server è più recente!"); } } catch (Exception exv1) { cGB.MsgBox(exv1.Message, MessageBoxIcon.Error); } } } catch { //error b = false; } } } catch { // display an error message to the user b = false; } return(b); }
static void Main(string[] args) { EmailSending email = new EmailSending(); email.EmailSend("smtp.mail.ru", "*****@*****.**", "krienglish92", "*****@*****.**", "MySubject", "Hello, it's a test mail"); }