public void Send(MailStructure s) { try { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(Settings.Default.HostMail); mailMessage.To.Add(_mailadress); mailMessage.Subject = "Bestellung: " + s.Ordernumber + " || " + s.Location + " ||"; MailAddress cc = new MailAddress(Settings.Default.HostMail); mailMessage.Body = s.Body; SmtpClient smtpClient = new SmtpClient(_hostserver, _port); mailMessage.CC.Add(cc); smtpClient.Credentials = new NetworkCredential(_hostserverusername, s.MailPassword); if (Apply.ConfirmSend()) { smtpClient.Send(mailMessage); Sent = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); Sent = false; } }
private async void button_order_Click(object sender, EventArgs e) { if (listView_warenkorb.Items.Count > 0) //Wenn mindestens ein Item im Warenkorb sind kann Bestellt werden { string mail; if (radioButton_defaultmail.Checked) { mail = Settings.Default.Mail; } else { mail = textBox_othermail.Text; } Orders b = new Orders(); //Letzte Bestellnummer aus der Liste lesen int lastId = b.Bestellblatt[b.Bestellblatt.Count - 1].Number + 1; _m = new Mail(mail); MailStructure str = new MailStructure { Ordernumber = lastId, Body = Orders.BuildMail(_w, GetLocation()), Location = GetLocation(), MailPassword = Configuration.GetRegistryPassword(_login) }; pictureBox_bottom.Enabled = true; pictureBox_bottom.Visible = true; await Task.Factory.StartNew(() => { _m.Send(str); }); if (_m.Sent) { b.WriteOrdersToFile(_w, lastId); _w = new Cart(); UpdateGoodslist(); } pictureBox_bottom.Visible = false; pictureBox_bottom.Enabled = false; } }
public override void Send(MailStructure mailStructure) { Console.WriteLine(string.Format("Title: {0}\nText: {1}\nDescription: Mail send from gmail", mailStructure.Title, mailStructure.Text)); }
public override void Send(MailStructure mailStructure) => Console.WriteLine($"Title: {mailStructure.Title}\nText: {mailStructure.Text}\nDescription: The mail send via gmail service..!");
public abstract void Send(MailStructure mailStructure);