MailBee.NET Objects 4.0

Smtp Class

Provides properties and methods for sending messages using the SMTP protocol.

For a list of all members of this type, see Smtp Members.

System.Object
   MailBee.InternalUse.LengthyTaskEventSink
      MailBee.InternalUse.SocketEventSink
         MailBee.InternalUse.SessionProtocolEventSink
            MailBee.InternalUse.SmtpEventSink
               MailBee.SmtpMail.Smtp

public class Smtp : SmtpEventSink, IComponent, IDisposable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

You can perform the following operations using this class:

Example

This sample sends plain-text message to the SMTP server.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.SmtpMail;

// The actual code (put it into a method of your class).

Smtp mailer = new Smtp();

// Set the message fields.
mailer.From.AsString = "John Doe <jdoe@domain1.com>";
mailer.To.AsString = "Bill Smith <b.smith@domain2.com>";
mailer.Subject = "Weekly newsletter";
mailer.BodyPlainText = "This is the newsletter contents";

// Specify the server to use. If your server does not require authentication, 
// just remove last 2 parameters.
mailer.SmtpServers.Add("smtp.domain1.com", "jdoe", "secret");

// Send the message.
mailer.Send();

Console.WriteLine("The message was successfully submitted to the server.");
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.SmtpMail

' The actual code (put it into a method of your class).

Dim mailer As New Smtp

' Set the message fields.
mailer.From.AsString = "John Doe <jdoe@domain1.com>"
mailer.To.AsString = "Bill Smith <b.smith@domain2.com>"
mailer.Subject = "Weekly newsletter"
mailer.BodyPlainText = "This is the newsletter contents"

' Specify the server to use. If your server does not require authentication, 
' just remove last 2 parameters.
mailer.SmtpServers.Add("smtp.domain1.com", "jdoe", "secret")

' Send the message.
mailer.Send()

Console.WriteLine("The message was successfully submitted to the server.")

Requirements

Namespace: MailBee.SmtpMail

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

Smtp Members | MailBee.SmtpMail Namespace