MailBee.NET Objects 7.1

Smtp.Message Property

Gets or sets the mail message which will be sent by the component on Send method call.

public MailBee.Mime.MailMessage Message {get; set;}

Property Value

The MailMessage object representing the mail message which will be sent by the component on Send method call.

Remarks

The developer can also use Message property to access those methods and properties of the message to be sent which are not available in Smtp class itself. For instance, LoadBodyText method is not available in Smtp class, and must be called as Smtp.Message.LoadBodyText(parameters).

Some most often used members of MailMessage object are available through Smtp class members. For instance, the following notations are equivalent: Smtp.Message.BodyHtmlText and Smtp.BodyHtmlText.

Exceptions

Exception TypeCondition
MailBeeInvalidArgumentExceptionvalue is a null reference (Nothing in Visual Basic).

Example

This sample composes the message by downloading the message body from a web page, and sends the message to a relay SMTP server (direct send mode is not used).

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

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

Smtp mailer = new Smtp();

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

// Compose the message.
mailer.From.AsString = "John Doe <jdoe@domain.com>";
mailer.To.AsString = "Support Team <support@afterlogic.com>";
mailer.Subject = "Error on your homepage";

mailer.Message.LoadBodyText("http://www.afterlogic.com", MessageBodyType.Html);

// Send it.
mailer.Send();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.SmtpMail
Imports MailBee.Mime

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

Dim mailer As New Smtp

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

' Compose the message.
mailer.From.AsString = "John Doe <jdoe@domain.com>"
mailer.To.AsString = "Support Team <support@afterlogic.com>"
mailer.Subject = "Error on your homepage"

mailer.Message.LoadBodyText("http://www.afterlogic.com", MessageBodyType.Html)

' Send it.
mailer.Send()

See Also

Smtp Class | MailBee.SmtpMail Namespace