原创|使用教程|编辑:黄竹雯|2017-05-03 17:41:00.000|阅读 387 次
概述:该文主要介绍了MailBee.NET Objects中发送包含纯文本和HTML格式主体的邮件,并添加.xls文档附加。欢迎您下载试用版进行运用!
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
相关链接:
C#:
MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body"); |
VB.NET:
MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body") |
C#:
MailBee.SmtpMail.Smtp.QuickSend("From Me <me@domain.com> (Company Info)", "To you <you@company.com>", "Subject", "Plain text body", "<html>HTML-formatted body</html>", null, @"C:\My Documents\report.doc"); |
VB.NET:
MailBee.SmtpMail.Smtp.QuickSend("From Me <me@domain.com> (Company Info)", _ "To you <you@company.com>", _ "Subject", "Plain text body", _ "«html»HTML-formatted body«/html»", _ Nothing, "C:\My Documents\report.doc") |
C#:
Smtp oMailer = new Smtp(); |
VB.NET:
Dim oMailer As New Smtp() |
C#:
oMailer.SmtpServers.Add("smtp.domain.com"); |
VB.NET:
oMailer.SmtpServers.Add("smtp.domain.com") |
C#:
oMailer.SmtpServers.Add("127.0.0.1"); |
VB.NET:
oMailer.SmtpServers.Add("127.0.0.1") |
C#:
oMailer.SmtpServers.Add("smtp.domain.com","login","password"); |
VB.NET:
oMailer.SmtpServers.Add("smtp.domain.com","login","password") |
C#:
oMailer.SmtpServers.Add("127.0.0.1","login","password"); |
VB.NET:
oMailer.SmtpServers.Add("127.0.0.1","login","password") |
C#:
oMailer.From.AsString = "Dan Brown <dan@domain.com> (Company Info)"; |
VB.NET:
oMailer.From.AsString = "Dan Brown <dan@domain.com> (Company Info)" |
C#:
oMailer.From.AsString = "Dan Brown <dan@domain.com>"; |
VB.NET:
oMailer.From.AsString = "Dan Brown <dan@domain.com>" |
C#:
oMailer.From.AsString = "dan@domain.com"; |
VB.NET:
oMailer.From.AsString = "dan@domain.com" |
C#:
oMailer.To.AsString = "Bill Smith <b.smith@domain.com> (Remarks), Kathy@mail.com "; oMailer.Cc.AsString = "Joe Black <j.black@domain.com>, Joseph <joseph@domain.com>"; oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com"; oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones <b.jones@mail.com>"; |
VB.NET:
oMailer.To.AsString = "Bill Smith <b.smith@domain.com> (Remarks), Kathy@mail.com " oMailer.Cc.AsString = "Joe Black <j.black@domain.com>, Joseph <joseph@domain.com>" oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com" oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones <b.jones@mail.com>" |
C#:
oMailer.Subject = "Test message"; |
VB.NET:
oMailer.Subject = "Test message" |
C#:
oMailer.BodyPlainText = "This is a test e-mail message."; |
VB.NET:
oMailer.BodyPlainText = "This is a test e-mail message." |
C#:
oMailer.BodyHtmlText = @"<DIV>Test HTML message.</DIV><BR><BR> <FONT face=""Arial Black"" color=#0000ff size=5> <P align=left><STRONG><U> This is a test HTML mes-sage. </U></STRONG></P></FONT> <hr size=1> <a href=""//www.afterlogic.com"">www.afterlogic.com</a>"; |
VB.NET:
oMailer.BodyHtmlText = "<DIV>Test HTML message.</DIV><BR><BR>" & vbCrLf & _
"<FONT face=""Arial Black"" color=#0000ff size=5>" & vbCrLf & _
"<P align=left><STRONG><U>" & vbCrLf & _ "This is a test HTML mes-sage." & vbCrLf & _ "</U></STRONG></P></FONT>" & vbCrLf & _ "<hr size=1>" & vbCrLf & _ "<a href=""//www.afterlogic.com"">www.afterlogic.com</a>" |
C#:
oMailer.AddAttachment(@"C:\annual_reoprt.xls"); oMailer.AddAttachment(@"C:\deposits.doc"); |
VB.NET:
oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.AddAttachment("C:\deposits.doc") |
C#:
try { oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail); } |
VB.NET:
Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail) End Try |
C#:
using System;
using MailBee; using MailBee.SmtpMail; namespace EmailApp
{ class Class1 { [STAThread] static void Main(string[] args) { Smtp oMailer = new Smtp(); oMailer.From.AsString = "John Doe <j.doe@domain.com> (Company Info)";
oMailer.To.AsString = "Bill Smith <b.smith@domain.com>, Kathy Ritchie <kr@compay.com> (Company Info)";
oMailer.Subject = "Test e-mail";
oMailer.BodyPlainText = "This is a test e-mail message.";
oMailer.BodyHtmlText = @"<DIV>Test HTML message.</DIV><BR><BR>
<FONT face=""Arial Black"" color=#0000ff size=5> <P align=left><STRONG><U> This is a test HTML mes-sage. </U></STRONG></P></FONT> <hr size=1> <a href=""//www.afterlogic.com"">www.afterlogic.com</a>"; oMailer.AddAttachment(@"C:\annual_reoprt.xls");
oMailer.SmtpServers.Add("127.0.0.1", "login", "password");
oMailer.SmtpServers[0].AllowRefusedRecipients = false;
try
{ oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail); } } } } |
VB.NET:
Imports System Imports MailBee Imports MailBee.SmtpMail Namespace EmailApp Class Class1 _ Shared Sub Main(ByVal args() As String) Dim oMailer As New Smtp() oMailer.From.AsString = "John Doe <j.doe@domain.com> (Company Info)" oMailer.To.AsString = "Bill Smith <b.smith@domain.com>, Kathy Ritchie <kr@compay.com> (Company Info)" oMailer.Subject = "Test e-mail" oMailer.BodyPlainText = "This is a test e-mail message." oMailer.BodyHtmlText = "<DIV>Test HTML message.</DIV><BR><BR>" & vbCrLf & _ "<FONT face=""Arial Black"" color=#0000ff size=5>" & vbCrLf & _ "<P align=left><STRONG><U>" & vbCrLf & _ "This is a test HTML mes-sage." & vbCrLf & _ "</U></STRONG></P></FONT>" & vbCrLf & _ "<hr size=1>" & vbCrLf & _ "<a href=""//www.afterlogic.com"">www.afterlogic.com</a>" oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.SmtpServers.Add("127.0.0.1", "login", "password") oMailer.SmtpServers(0).AllowRefusedRecipients = False Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail) End Try End Sub End Class End Namespace |
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn