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 static void SetMailBodyEncoding(MimeBody body, BodyFormat format) { body.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable; body.Charset = "ISO-8859-1"; body.Format = format; }
public static FileStream CreateUploadData(Stream imageStream, string filename, IDictionary<string, string> parameters, string boundary) { var body = new MimeBody { Boundary = boundary, MimeParts = parameters .Where(p => !p.Key.StartsWith("oauth_")) .Select(p => (MimePart)new FormDataPart { Name = p.Key, Value = p.Value }).ToList() }; var binaryPart = new BinaryPart { Name = "photo", ContentType = "image/jpeg", Filename = filename }; binaryPart.LoadContent(imageStream); body.MimeParts.Add(binaryPart); var stream = new FileStream(Path.GetTempFileName(), FileMode.Create); body.WriteTo(stream); stream.Position = 0; return stream; }
private void ProcessMessage(string filename) { MimeMessage msg = new MimeMessage(); StreamReader content = new StreamReader(filename); msg.LoadBody(content.ReadToEnd()); content.Close(); ArrayList bodylist = new ArrayList(); msg.GetBodyPartList(bodylist); EventLogManager.WriteEntry(string.Format("Loaded {0} parts of message \"{1}\".", bodylist.Count, filename)); List <MimeDSNRecipient> failures = new List <MimeDSNRecipient>(); for (int i = 0; i < bodylist.Count; i++) { MimeBody ab = (MimeBody)bodylist[i]; EventLogManager.WriteEntry(string.Format("Parsing body part {0}: \"{1}\" ({2}).", i, ab.GetName(), ab.GetContentType())); switch (ab.GetContentType()) { case "message/delivery-status": /// TODO: move to Mime processor MimeDSN dsn = new MimeDSN(); dsn.LoadBody(ab.GetText()); foreach (MimeDSNRecipient r in dsn.Recipients) { if (IsStopping) { break; } EventLogManager.WriteEntry(string.Format("Checking {0} ({1}).", r.FinalRecipientEmailAddress, r.Action)); switch (r.Action) { case "failed": failures.Add(r); break; } } break; } } if (failures.Count > 0) { foreach (MimeDSNRecipient r in failures) { if (IsStopping) { break; } EventLogManager.WriteEntry(string.Format("Processing {0} ({1}).", r.FinalRecipientEmailAddress, r.Action)); UpdateFailure(r); } } EventLogManager.WriteEntry(string.Format("Processed message \"{0}\".", filename)); }