C#: SmtpServer smtp_srv = new SmtpServer(); smtp_srv.Name = "mail.domain.com"; oMailer.SmtpServers.Add(smtp_srv); |
VB.NET: Dim smtp_srv As SmtpServer = New SmtpServer() smtp_srv.Name = "mail.domain.com" smtp_srv.AccountName = "john_doe" smtp_srv.Password = "secret" oMailer.SmtpServers.Add(smtp_srv) |
C#: oMailer.SmtpServers.Add("127.0.0.1"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1") oMailer.SmtpServers.Add("smtp.company.com") |
C#: oMailer.SmtpServers.Add("127.0.0.1", 33, 1); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1", 33, 1) oMailer.SmtpServers.Add("smtp.company.com", 37, 2) |
C#: oMailer.SmtpServers.Add("127.0.0.1", "dan_brown", "password"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1", "dan_brown", "password") oMailer.SmtpServers.Add("smtp.company.com ", "john_doe", "secret") |
C# MailMessage msg = pop.DownloadEntireMessage(1); msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml; VB.NET Dim msg As MailMessage = pop.DownloadEntireMessage(1) msg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
C# Response.Write(msg.BodyHtmlText); VB.NET Response.Write(msg.BodyHtmlText)
C# msg.Parser.HeadersAsHtml = true; Response.Write("From: " + msg.From.ToString()); VB.NET msg.Parser.HeadersAsHtml = True Response.Write("From: " + msg.From.ToString())
C# // Create SMTP object Smtp mailer = new Smtp(); // Set the message fields. mailer.From.AsString = "jdoe@domain.com"; mailer.To.AsString = "bill@domain2.com"; mailer.Subject = "Hi"; mailer.BodyPlainText = "This is test message"; // Starts logging SMTP activities into a file. mailer.Log.Enabled = true; mailer.Log.Filename = @"C:\log.txt"; mailer.Log.Clear(); // Specify the server to use. If your server does not require authentication, // just omit both last parameters. mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret"); // Attempt to connect. mailer.Connect(); // Display the host name of the server the connection was established with. Console.WriteLine("Connected to " + mailer.SmtpServers[mailer.GetCurrentSmtpServerIndex()].Name); // Make sure all the recipients are ok. if (mailer.TestSend(SendFailureThreshold.AllRecipientsFailed) != TestSendResult.OK) { Console.WriteLine("No recipients can receive the message."); }// Show refused recipients if any else if (mailer.GetRefusedRecipients().Count > 0) { Console.WriteLine("The following recipients failed: " + mailer.GetRefusedRecipients().ToString()); } else { Console.WriteLine("All recipients are ok. Will send the message now."); // Send e-mail. If it cannot be delivered, bounce will // arrive to bounce@domain3.com, not to joe@domain1.com mailer.Send("bounce@domain.com", (string)null); Console.WriteLine("Sent to: " + mailer.GetAcceptedRecipients().ToString()); } // Disconnect from the server mailer.Disconnect();
VB.NET ' Create SMTP object Dim mailer As New Smtp ' Set the message fields. mailer.From.AsString = "jdoe@domain.com" mailer.To.AsString = "bill@domain2.com" mailer.Subject = "Hi" mailer.BodyPlainText = "This is test message" ' Starts logging SMTP activities into a file. mailer.Log.Enabled = True mailer.Log.Filename = "C:\log.txt" mailer.Log.Clear() ' Specify the server to use. If your server does not require authentication, ' just remove last 2 parameters. mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret") ' Attempt to connect. mailer.Connect() ' Display the host name of the server the connection was established with. Console.WriteLine("Connected to " + mailer.SmtpServers(mailer.GetCurrentSmtpServerIndex()).Name) ' Make sure all the recipients are ok. If mailer.TestSend(SendFailureThreshold.AllRecipientsFailed) <> TestSendResult.OK Then Console.WriteLine("No recipients can receive the message.") Else ' Show refused recipients if any If mailer.GetRefusedRecipients().Count > 0 Then Console.WriteLine("The following recipients failed: " & mailer.GetRefusedRecipients().ToString()) Else Console.WriteLine("All recipients are ok. Will send the message now.") ' Send e-mail. If it cannot be delivered, bounce will ' arrive to bounce@domain3.com, not to joe@domain1.com mailer.Send("bounce@domain.com", CType(Nothing, String)) Console.WriteLine("Sent to: " + mailer.GetAcceptedRecipients().ToString()) End If End If ' Disconnect from the server mailer.Disconnect()
慧都十四周年狂欢开启,Dynamic Web TWAIN终极让利7折特惠
限时一个月,错过不再有,马上咨询>>>