private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We add the embedded objets. string bodyHtml = string.Empty; for (int i = 0; i < _lvEmbeddedObject.Items.Count; i++) { message.EmbeddedObjects.Add((string)((Utils.ItemTag)_lvEmbeddedObject.Items[i]).Tag, true); bodyHtml += "<img src = \"cid:" + message.EmbeddedObjects[i].ContentId + "\" />"; } message.Send("mail.example.com", 25, "*****@*****.**", "userpassword", SaslMechanism.CramMd5); message.BodyHtml.Format = BodyFormat.Html; if (bodyHtml.Length > 0) { message.BodyHtml.Text = bodyHtml; } else { message.BodyHtml.Text = "The message doens't contain embedded objects."; } // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We add the embedded objets. string bodyHtml = string.Empty; for (int i = 0; i < _lvEmbeddedObject.Items.Count; i++) { message.EmbeddedObjects.Add((string)((Utils.ItemTag)_lvEmbeddedObject.Items[i]).Tag, true); bodyHtml += "<img src = \"cid:" + message.EmbeddedObjects[i].ContentId + "\" />"; } message.Send("mail.example.com", 25, "*****@*****.**", "userpassword", SaslMechanism.CramMd5); message.BodyHtml.Format = BodyFormat.Html; if (bodyHtml.Length > 0) { message.BodyHtml.Text = bodyHtml; } else { message.BodyHtml.Text = "The message doens't contain embedded objects."; } // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the return recipient email message.ReturnReceipt.Email = this._tbReturnReceipt.Text; // We assign the confirmation read email message.ConfirmRead.Email = this._tbConfirmReadEmail.Text; // We assign the reply to email message.ReplyTo.Email = this._tbReplyTo.Text; // We assign the comments message.Comments = this._tbComments.Text; // We assign the mime type. message.ContentType.MimeType = "text/html"; // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the return recipient email message.ReturnReceipt.Email = this._tbReturnReceipt.Text; // We assign the confirmation read email message.ConfirmRead.Email = this._tbConfirmReadEmail.Text; // We assign the reply to email message.ReplyTo.Email = this._tbReplyTo.Text; // We assign the comments message.Comments = this._tbComments.Text; // We assign the mime type. message.ContentType.MimeType = "text/html"; // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // It is required to build the mime part tree before signing message.BuildMimePartTree(); if (_tbCertificate.Text != string.Empty) { CmsSigner signer = new CmsSigner(new X509Certificate2(_tbCertificate.Text)); // Here we only want the signer's certificate to be sent along. Not the whole chain. signer.IncludeOption = X509IncludeOption.EndCertOnly; message.SmimeAttachSignatureBy(signer); } // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void sendMessageButton_Click(object sender, EventArgs e) { if (this.attachmentsListbox.Items.Count > 0) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this.fromEmailTextbox.Text; // We assign the recipient email message.To.Add(this.toEmailTextbox.Text); // We assign the subject message.Subject = this.subjectTextbox.Text; // We assign the body text message.BodyText.Text = this.bodyTextTextbox.Text; // We now add each attachments foreach (string attachmentPath in this.attachmentsListbox.Items) { message.Attachments.Add(attachmentPath, false); } message.BuildMimePartTree(); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this.smtpServerAddressTextbox.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } } else { MessageBox.Show("Please add an attachment before sending this test message."); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // It is required to build the mime part tree before signing message.BuildMimePartTree(); if (_tbCertificate.Text != string.Empty) { CmsSigner signer = new CmsSigner(new X509Certificate2(_tbCertificate.Text)); // Here we only want the signer's certificate to be sent along. Not the whole chain. signer.IncludeOption = X509IncludeOption.EndCertOnly; message.SmimeAttachSignatureBy(signer); } // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { if (this._lvAttachments.Items.Count > 0) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We now add each attachments foreach (string attachmentPath in this._lvAttachments.Items) { message.Attachments.Add(attachmentPath, false); } // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } } else { MessageBox.Show("Please add an attachment before sending this test message."); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); try { // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // It is required to build the mime part tree before encrypting message.BuildMimePartTree(); // Encrypt the message. You need the recipient(s) certificate(s) (with public key only). X509Certificate2 recipientCertificate = new X509Certificate2(_tbRecipientCertificate.Text); CmsRecipient recipient = new CmsRecipient(recipientCertificate); message.SmimeEnvelopeAndEncryptFor(recipient); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _tbSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We use base 64 encoding message.ContentTransferEncoding = (ContentTransferEncoding)Enum.Parse(typeof(ContentTransferEncoding), (string)_comboTransfertEncoding.SelectedItem, true); // We set the charset message.Charset = ((ComboItem)_comboCharset.SelectedItem).Value; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; ServerCollection smtpServers = new ServerCollection(); smtpServers.Add(this._tbMainSmtpServer.Text); smtpServers.Add(this._tbBackupSmtpServer.Text); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(smtpServers); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _tbSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We use base 64 encoding message.ContentTransferEncoding = ContentTransferEncoding.Base64; message.BuildMimePartTree(); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _tbSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We use base 64 encoding message.ContentTransferEncoding = ContentTransferEncoding.Base64; message.BuildMimePartTree(); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; //Add the recipients e mail ids foreach (ListViewItem lvi in _lvToEmail.Items) { message.To.Add(lvi.Text); } // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void sendMessageButton_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this.fromEmailTextbox.Text; // We assign the recipient email message.To.Add(this.toEmailTextbox.Text); // We assign the subject message.Subject = this.subjectTextbox.Text; // We assign the body text message.BodyText.Text = this.bodyTextTextbox.Text; ServerCollection smtpServers = new ServerCollection(); smtpServers.Add(this.smtpServerAddressTextbox.Text); smtpServers.Add(this.backupSmtpServerAddressTextbox.Text); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(smtpServers); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void sendMessageButton_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this.fromEmailTextbox.Text; // We assign the recipient email message.To.Add(this.toEmailTextbox.Text); // We assign the subject message.Subject = this.subjectTextbox.Text; // We assign the body text message.BodyText.Text = this.bodyTextTextbox.Text; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this.smtpServerAddressTextbox.Text, Convert.ToInt32(this.portTextbox.Text), this.loginTextbox.Text, this.passwordTextbox.Text, SaslMechanism.Login); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _bSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); try { // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // It is required to build the mime part tree before encrypting message.BuildMimePartTree(); // Encrypt the message. You need the recipient(s) certificate(s) (with public key only). X509Certificate2 recipientCertificate = new X509Certificate2(_tbRecipientCertificate.Text); CmsRecipient recipient = new CmsRecipient(recipientCertificate); message.SmimeEnvelopeAndEncryptFor(recipient); // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
private void _tbSendMessage_Click(object sender, EventArgs e) { this.AddLogEntry("Creating message."); // We create the message object ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); // We assign the sender email message.From.Email = this._tbFromEmail.Text; // We assign the recipient email message.To.Add(this._tbToEmail.Text); // We assign the subject message.Subject = this._tbSubject.Text; // We assign the body text message.BodyText.Text = this._tbBodyText.Text; // We use base 64 encoding message.ContentTransferEncoding = (ContentTransferEncoding)Enum.Parse(typeof(ContentTransferEncoding), (string)_comboTransfertEncoding.SelectedItem, true); // We set the charset message.Charset = ((ComboItem)_comboCharset.SelectedItem).Value; // We send the email using the specified SMTP server this.AddLogEntry("Sending message."); try { message.Send(this._tbSmtpServer.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }
public void Send(object sender, System.EventArgs e) { ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message(); try { message.Subject = iSubject.Text; message.To = ActiveUp.Net.Mail.Parser.ParseAddresses(iTo.Text); message.Cc = ActiveUp.Net.Mail.Parser.ParseAddresses(iCc.Text); message.Bcc = ActiveUp.Net.Mail.Parser.ParseAddresses(iBcc.Text); if (iReplyTo.Text.Length > 0) message.ReplyTo = ActiveUp.Net.Mail.Parser.ParseAddresses(iReplyTo.Text)[0]; string s1 = iBody.Text; string[] sArr1 = System.IO.Directory.GetFiles(Page.Server.MapPath(Application["writedirectory\uFFFD"].ToString())); for (int i1 = 0; i1 < sArr1.Length; i1++) { string s2 = sArr1[i1]; if ((s2.IndexOf(Session.SessionID + "_Image_\uFFFD") != -1) && (s1.IndexOf(s2.Substring(s2.IndexOf(Session.SessionID))) != -1)) { ActiveUp.Net.Mail.MimePart embeddedObject1 = new ActiveUp.Net.Mail.MimePart(s2, true, string.Empty); embeddedObject1.ContentName = s2.Substring(s2.IndexOf("_Image_\uFFFD") + 7); message.EmbeddedObjects.Add(embeddedObject1); s1 = s1.Replace("http://\uFFFD" + Request.ServerVariables["HTTP_HOST\uFFFD"] + Request.ServerVariables["URL\uFFFD"].Substring(0, Request.ServerVariables["URL\uFFFD"].LastIndexOf("/\uFFFD") + 1) + "temp\uFFFD" + s2.Substring(s2.LastIndexOf('\\')).Replace("\\\uFFFD", "/\uFFFD"), "cid:\uFFFD" + embeddedObject1.ContentId); s1 = s1.Replace("temp\uFFFD" + s2.Substring(s2.LastIndexOf('\\')).Replace("\\\uFFFD", "/\uFFFD"), "cid:\uFFFD" + embeddedObject1.ContentId); } } string[] sArr3 = System.IO.Directory.GetFiles(Server.MapPath("icons/emoticons/\uFFFD")); for (int i2 = 0; i2 < sArr3.Length; i2++) { string s3 = sArr3[i2]; if (s1.IndexOf("icons/emoticons\uFFFD" + s3.Substring(s3.LastIndexOf("\\\uFFFD")).Replace("\\\uFFFD", "/\uFFFD")) != -1) { ActiveUp.Net.Mail.MimePart embeddedObject2 = new ActiveUp.Net.Mail.MimePart(s3, true, string.Empty); embeddedObject2.ContentName = s3.Substring(s3.LastIndexOf("\\\uFFFD") + 1); message.EmbeddedObjects.Add(embeddedObject2); s1 = s1.Replace("http://\uFFFD" + Request.ServerVariables["HTTP_HOST\uFFFD"] + Request.ServerVariables["URL\uFFFD"].Substring(0, Request.ServerVariables["URL\uFFFD"].LastIndexOf("/\uFFFD") + 1) + "icons/emoticons\uFFFD" + s3.Substring(s3.LastIndexOf('\\')).Replace("\\\uFFFD", "/\uFFFD"), "cid:\uFFFD" + embeddedObject2.ContentId); } } message.BodyHtml.Text = s1; message.BodyText.Text = iBody.TextStripped; //message.Headers.Add("x-sender-ip\uFFFD", Request.ServerVariables["REMOTE_ADDR\uFFFD"]); string[] sArr5 = System.IO.Directory.GetFiles(Page.Server.MapPath(Application["writedirectory\uFFFD"].ToString())); for (int i3 = 0; i3 < sArr5.Length; i3++) { string s4 = sArr5[i3]; if (s4.IndexOf("\\temp\\\uFFFD" + Session.SessionID + "_Attach_\uFFFD") != -1) { ActiveUp.Net.Mail.MimePart attachment = new ActiveUp.Net.Mail.MimePart(s4, true); attachment.Filename = s4.Substring(s4.IndexOf("_Attach_\uFFFD") + 8); attachment.ContentName = s4.Substring(s4.IndexOf("_Attach_\uFFFD") + 8); message.Attachments.Add(attachment); } } message.From = new ActiveUp.Net.Mail.Address(iFromEmail.Text, iFromName.Text); if (((System.Web.UI.HtmlControls.HtmlInputButton)sender).ID == "iSubmit\uFFFD") { try { message.Send((string)Application["smtpserver\uFFFD"], System.Convert.ToInt32(Application["smtpport\uFFFD"]), (string)Application["user\uFFFD"], (string)Application["password\uFFFD"], ActiveUp.Net.Mail.SaslMechanism.CramMd5); } catch { try { message.Send((string)Application["smtpserver\uFFFD"], System.Convert.ToInt32(Application["smtpport\uFFFD"]), (string)Application["user\uFFFD"], (string)Application["password\uFFFD"], ActiveUp.Net.Mail.SaslMechanism.CramMd5); } catch { message.Send((string)Application["smtpserver\uFFFD"], System.Convert.ToInt32(Application["smtpport\uFFFD"])); } } try { if (iAction.Value == "r\uFFFD") { ActiveUp.Net.Mail.Mailbox mailbox1 = ((ActiveUp.Net.Mail.Imap4Client)Session["imapobject\uFFFD"]).SelectMailbox(MailboxName); ActiveUp.Net.Mail.FlagCollection flagCollection = new ActiveUp.Net.Mail.FlagCollection(); flagCollection.Add("Answered\uFFFD"); if (mailbox1.Fetch.Flags(MessageId).Merged.ToLower().IndexOf("\\answered\uFFFD") == -1) mailbox1.AddFlagsSilent(MessageId, flagCollection); } lConfirm.Text = ((Language)Session["language\uFFFD"]).Words[32].ToString() + " : <br /><br />\uFFFD" + message.To.Merged + message.Cc.Merged + message.Bcc.Merged.Replace(";\uFFFD", "<br />\uFFFD"); pForm.Visible = false; pConfirm.Visible = true; System.Web.HttpCookie httpCookie1 = new System.Web.HttpCookie("fromname\uFFFD", iFromName.Text); System.Web.HttpCookie httpCookie2 = new System.Web.HttpCookie("fromemail\uFFFD", iFromEmail.Text); System.Web.HttpCookie httpCookie3 = new System.Web.HttpCookie("replyto\uFFFD", iReplyTo.Text); System.DateTime dateTime1 = System.DateTime.Now; httpCookie1.Expires = dateTime1.AddMonths(2); System.DateTime dateTime2 = System.DateTime.Now; httpCookie2.Expires = dateTime2.AddMonths(2); System.DateTime dateTime3 = System.DateTime.Now; httpCookie3.Expires = dateTime3.AddMonths(2); Response.Cookies.Add(httpCookie1); Response.Cookies.Add(httpCookie2); Response.Cookies.Add(httpCookie3); if (cSave.Checked) { System.Web.HttpCookie httpCookie4 = new System.Web.HttpCookie("folder\uFFFD", dBoxes.SelectedItem.Text); System.DateTime dateTime4 = System.DateTime.Now; httpCookie4.Expires = dateTime4.AddMonths(2); Response.Cookies.Add(httpCookie4); ActiveUp.Net.Mail.Mailbox mailbox2 = ((ActiveUp.Net.Mail.Imap4Client)Session["imapobject\uFFFD"]).SelectMailbox(dBoxes.SelectedItem.Text); mailbox2.Append(message.ToMimeString()); } string[] sArr6 = System.IO.Directory.GetFiles(Page.Server.MapPath(Application["writedirectory\uFFFD"].ToString())); for (int i4 = 0; i4 < sArr6.Length; i4++) { string s5 = sArr6[i4]; if (s5.IndexOf(Session.SessionID) != -1) System.IO.File.Delete(s5); } } catch (System.Exception e1) { Page.RegisterStartupScript("ShowError\uFFFD", "<script>ShowErrorDialog('\uFFFD" + ((Language)Session["language\uFFFD"]).Words[83].ToString() + "','\uFFFD" + System.Text.RegularExpressions.Regex.Escape(e1.Message + e1.StackTrace).Replace("'\uFFFD", "\\'\uFFFD") + "');</script>\uFFFD"); } } else { System.Web.HttpCookie httpCookie5 = new System.Web.HttpCookie("folder\uFFFD", dBoxes.SelectedItem.Text); System.DateTime dateTime5 = System.DateTime.Now; httpCookie5.Expires = dateTime5.AddMonths(2); Response.Cookies.Add(httpCookie5); ActiveUp.Net.Mail.Mailbox mailbox3 = ((ActiveUp.Net.Mail.Imap4Client)Session["imapobject\uFFFD"]).SelectMailbox(dBoxes.SelectedItem.Text); mailbox3.Append(message.ToMimeString()); } string[] sArr8 = System.IO.Directory.GetFiles(Page.Server.MapPath(Application["writedirectory\uFFFD"].ToString())); for (int i5 = 0; i5 < sArr8.Length; i5++) { string s6 = sArr8[i5]; if (s6.IndexOf(Session.SessionID) != -1) System.IO.File.Delete(s6); } } catch (System.Exception e2) { Page.RegisterStartupScript("ShowError\uFFFD", "<script>ShowErrorDialog('\uFFFD" + ((Language)Session["language\uFFFD"]).Words[82].ToString() + "','\uFFFD" + System.Text.RegularExpressions.Regex.Escape(e2.Message + e2.StackTrace).Replace("'\uFFFD", "\\'\uFFFD") + "');</script>\uFFFD"); } }
private void sendMessageButton_Click(object sender, EventArgs e) { // Let us create a data source in this case Hastable that would // used to demonstrate the merging // Take the form variables collection as the data source. Hashtable dataSource = new Hashtable(); dataSource.Add("FIRSTNAME", "John"); dataSource.Add("LASTNAME", "Richards"); dataSource.Add("MESSAGE", "This is a test mail."); dataSource.Add("VAR1", "This is a variable."); // We create the message object. Message message = new Message(); //We assign the sender email message.From.Email = this.fromEmailTextbox.Text; // We assign the recipient email message.To.Add(this.toEmailTextbox.Text); // We assign the subject message.Subject = this.subjectTextbox.Text; // We create the template. System.Text.StringBuilder messageTemplate = new System.Text.StringBuilder(); messageTemplate.Append("Request posted\n\n"); messageTemplate.Append("Firstname : $FIRSTNAME$\n"); messageTemplate.Append("Lastname : $LASTNAME$\n"); messageTemplate.Append("Message : $MESSAGE$\n"); message.BodyText.Text = messageTemplate.ToString(); Merger merger = new Merger(); // We merge our DataSource merger.MergeMessage(message, dataSource, false); //Handle the error in case any try { // We send the mail message.Send(smtpServerAddressTextbox.Text); this.AddLogEntry("Message sent successfully."); } catch (SmtpException ex) { this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } }