本文整理汇总了C#中ActiveUp.Net.Mail.Message.DirectSend方法的典型用法代码示例。如果您正苦于以下问题:C# Message.DirectSend方法的具体用法?C# Message.DirectSend怎么用?C# Message.DirectSend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveUp.Net.Mail.Message
的用法示例。
在下文中一共展示了Message.DirectSend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sendTestMessageButton_Click
private void sendTestMessageButton_Click(object sender, EventArgs e)
{
this.AddLogEntry("Sending test message using DirectSend()");
ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();
message.From.Email = this.emailAddressTextbox.Text;
message.To.Add(this.emailAddressTextbox.Text);
message.Subject = "This is a notification test.";
message.BodyText.Text = "This is a notification test.";
message.DirectSend();
this.AddLogEntry("Notification test message sent.");
}
示例2: 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;
message.BuildMimePartTree();
// We send the email using the specified SMTP server
this.AddLogEntry("Sending message.");
try
{
message.DirectSend();
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));
}
}