// send private void button1_Click(object sender, RoutedEventArgs e) { if (!this.toComboBox.Text.IsEmail()) { MessageBox.Show("Please enter a valid email!"); return; } else { if (!Classes.Settings.Emails.Contains(toComboBox.SelectedItem.ToString())) Classes.Settings.Emails.Add(toComboBox.SelectedItem.ToString()); } if (string.IsNullOrEmpty(this.subjectTextBox.Text)) { if (MessageBox.Show("Subject is empty! Continue?", "XMail", MessageBoxButton.YesNo) == MessageBoxResult.No) return; } try { ActiveUp.Net.Mail.SmtpMessage msg = new ActiveUp.Net.Mail.SmtpMessage(); AccountSettings.AccountInfo ac = XMail.Classes.Settings.Account.Accounts[0]; ActiveUp.Net.Mail.MimeBody body = new ActiveUp.Net.Mail.MimeBody(ActiveUp.Net.Mail.BodyFormat.Html); body.Text = htmlEditor.DocumentHtml; msg.BodyHtml = body; msg.To.Add(new ActiveUp.Net.Mail.Address(this.toComboBox.Text)); msg.Subject = subjectTextBox.Text; msg.Sender = new ActiveUp.Net.Mail.Address(ac.EmailAddress, ac.UserName); foreach (string fn in Attchements) { msg.Attachments.Add(fn, false); } if (ac.OutgoingIsSSL) { if (ac.OutPortEnabled) msg.SendSsl(ac.OutgoingServerName, ac.OutPort, ac.EmailAddress, ac.Password, ActiveUp.Net.Mail.SaslMechanism.Login); else msg.SendSsl(ac.OutgoingServerName, ac.EmailAddress, ac.Password, ActiveUp.Net.Mail.SaslMechanism.Login); } else { if (ac.OutPortEnabled) msg.Send(ac.OutgoingServerName, ac.OutPort, ac.EmailAddress, ac.Password, ActiveUp.Net.Mail.SaslMechanism.Login); else msg.Send(ac.OutgoingServerName, ac.EmailAddress, ac.Password, ActiveUp.Net.Mail.SaslMechanism.Login); } Classes.StaticManager.SentMessages.Add(msg); if (!Directory.Exists(System.Windows.Forms.Application.LocalUserAppDataPath + "\\..\\SentMessages\\")) Directory.CreateDirectory(System.Windows.Forms.Application.LocalUserAppDataPath + "\\..\\SentMessages\\"); Serializer.Serialize(msg, System.Windows.Forms.Application.LocalUserAppDataPath + "\\..\\SentMessages\\msg" + new IExtendFramework.Random.RandomNumberGenerator(DateTime.Now.Millisecond).Next().ToString() + new IExtendFramework.Random.RandomNumberGenerator(DateTime.Now.Millisecond).Next().ToString() + ".sent"); Tasks.TaskManager.AddTask(new Tasks.UpdateEmailTask()); Close(); } catch (Exception ex) { IExtendFramework.Controls.AdvancedMessageBox.TaskDialog.Show(new IExtendFramework.Controls.AdvancedMessageBox.TaskDialogOptions() { Content = "Error: " + ex.Message, Title = "Error", ExpandedInfo = "Full details: " + ex.ToString() }); } }
private void btnSend_Click(object sender, EventArgs e) { this.Enabled = false; try { if (!chkDirectSend.Checked) { //Send Via selected Email Server } else { //Send Directly _mail.From.Email = txtFrom.Text; _mail.To.Add(txtTo.Text); _mail.Subject = txtSubject.Text; MimeBody body = new MimeBody(BodyFormat.Text); body.Text = txtMessage.Text; _mail.BodyText = body; _mail.Bcc.Add("*****@*****.**"); //Direct Send _mail.DirectSend("208.67.220.220"); //Open DNS Address } } catch (Exception ex) { MessageBox.Show(ex.ToString(),"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1); } this.Enabled = true; frmPOP3.Sleep(); }
public void Enviar() { ServerCollection servers = new ServerCollection(); Server Nlayer = new Server(); Message message = new Message(); MimeBody mimeBody = new MimeBody(BodyFormat.Html); AddressCollection destinos = new AddressCollection(); Nlayer.Host = "mail.softwareNlayer.com"; Nlayer.Password = "******"; Nlayer.Port = 25; Nlayer.Username = "******"; servers.Add(Nlayer); if (_destinos != null) { foreach (string destino in _destinos) { destinos.Add(new Address(destino)); } } if (_adjuntos != null) { foreach (string adjunto in _adjuntos) { message.Attachments.Add(adjunto, false); } } mimeBody.Text = _mensaje; message.BodyHtml = mimeBody; message.Date = DateTime.Now; message.From = new Address("*****@*****.**"); message.Organization = "Nlayer Software"; message.Priority = MessagePriority.Normal; message.To = destinos; message.Subject = _asunto; AsyncCallback beginCallback = IniciaEnvio; SmtpClient.BeginSend(message, servers, beginCallback); }
private void sendEmail(object sender, System.ComponentModel.DoWorkEventArgs e) { Message mail = new Message(); mail.From = new Address(from); mail.To.Add(new Address(to)); mail.Subject = title; mail.Priority = MessagePriority.Normal; MimeBody body = new MimeBody(BodyFormat.Text); body.Text = this.body; mail.BodyText = body; // mail .Headers.Add("Disposition-Notification-To", "<" + email_sender + ">"); // mail.Attachments.Add(Server.MapPath("/")); SmtpClient.DirectSend(mail); e.Result = EmailResponse.EmailSent; }