本文整理汇总了C#中ActiveUp.Net.Mail.Message.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Send方法的具体用法?C# Message.Send怎么用?C# Message.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveUp.Net.Mail.Message
的用法示例。
在下文中一共展示了Message.Send方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _bSendMessage_Click
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, "[email protected]", "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));
}
}
示例2: _bSendMessage_Click
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));
}
}
示例3: _bSendMessage_Click
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));
}
}
示例4: _bSendMessage_Click
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.");
}
}
示例5: _tbSendMessage_Click
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));
}
}
示例6: _bSendMessage_Click
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));
}
}
示例7: sendMessageButton_Click
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));
}
}
示例8: _bSendMessage_Click
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));
}
}
示例9: Send
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);
//.........这里部分代码省略.........
示例10: _tbSendMessage_Click
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));
}
}
示例11: sendMessageButton_Click
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));
}
}