Table of Contents

Class Message

Namespace
Dynamicweb.Mailing
Assembly
Dynamicweb.Core.dll

A message object used for EmailMessaging.

public class Message
Inheritance
Message
Inherited Members

Examples

using System;

namespace Dynamicweb.Mailing.Examples
{
    class MessageRecipientSendingSample
    {
        public void SendMessage()
        {
            //Create a recipient collection and fill it with 100 recipients.
            var recipientCollection = new RecipientCollection();
            for (var i = 0; i < 100; i++)
            {
                var recipient = new Recipient();
                recipient.Name = "Test" + i;
                recipient.EmailAddress = string.Format("test{0}@testdomain.tld", i);
                recipientCollection.Add(recipient);
            }

            //Create a message that will be sent.
            var message = new Message();
            message.Subject = "This is a test email";
            message.HtmlBody = string.Format("<h1>Hello <!--@{0}--></h1><br /><p>This is a test</p>", Constants.TagRecipientName);
            message.SenderEmail = "webshop@mydomain.tld";
            message.SenderName = "Test Webshop";

            //Instanciate the MessagingHandler, which will start the process.
            //Using the CallbackHandler is reviewed in another example.
            var handler = new MessagingHandler(message, recipientCollection);
            var processStarted = handler.Process();

            //The boolean 'processStarted' indicated whether the process of preprocessing, merging and sending was started.
            //This process is run asynchronously in multiple threads to increase performance.
            if (!processStarted)
                throw new Exception("Sending could not be started");
        }
    }
}

Constructors

Message()

Creates a new Message instance.

public Message()

Properties

DeliveryProvider

Gets the delivery provider.

public MessageDeliveryProviderConfiguration DeliveryProvider { get; }

Property Value

MessageDeliveryProviderConfiguration

The delivery provider.

DeliveryProviderId

Gets or sets the delivery provider id.

public int DeliveryProviderId { get; set; }

Property Value

int

The delivery provider id.

DomainUrl

Gets or sets the domain URL.

public string? DomainUrl { get; set; }

Property Value

string

The domain URL.

Encoding

Gets or sets the encoding.

public Encoding Encoding { get; set; }

Property Value

Encoding

The encoding.

FileAttachmentPaths

Gets the file attachment paths.

public List<string> FileAttachmentPaths { get; }

Property Value

List<string>

HtmlBody

Gets or sets the HTML body.

public string? HtmlBody { get; set; }

Property Value

string

The HTML body.

Id

Gets the id.

public int Id { get; }

Property Value

int

IncludePlainTextBody

Gets or sets a value indicating whether to include the plain text body in a multi-part message.

public bool IncludePlainTextBody { get; set; }

Property Value

bool

true if plain body should be included; otherwise, false.

IsIncomplete

Determines whether this Message has any incomplete Recipients.

public bool IsIncomplete { get; }

Property Value

bool

True if message with specific id has incomplete recipients

IsNew

Gets a value indicating whether this instance is new.

public bool IsNew { get; }

Property Value

bool

true if this instance is new; otherwise, false.

IsPreprocessed

Gets or sets a value indicating whether this instance is preprocessed.

public bool IsPreprocessed { get; set; }

Property Value

bool

true if this instance is preprocessed; otherwise, false.

IsSending

Determines whether this Message is currently being sent.

public bool IsSending { get; }

Property Value

bool

True if message sending operation is in progress

LinkParameters

Gets a dictionary containing all additional parameters that will be added to the links. These parameters are not applied in Preview mode.

public Dictionary<string, string> LinkParameters { get; }

Property Value

Dictionary<string, string>

Gets the links.

public LinkCollection Links { get; }

Property Value

LinkCollection

PlainTextBody

Gets or sets the plain text body.

public string? PlainTextBody { get; set; }

Property Value

string

The plain body.

PreprocessedHtmlBody

Gets the preprocessed HTML body. This content is produced by the MessagePreprocessor which is called by the MessagingHandler.

public string? PreprocessedHtmlBody { get; set; }

Property Value

string

QuarantinePeriod

Gets or sets the quarantine period (in minutes). The period in which the same Recipient is quarantined from receiving this Message. This requires RequireUniqueRecipients to be se to false to have effect. Default is 0.

public int QuarantinePeriod { get; set; }

Property Value

int

The quarantine period. This cannot be negative. Default is 0, indicating no quarantine period.

RecipientContentProvider

Gets or sets the recipient content provider. This is used to provide recipient specific content. This is used if RecipientSpecificContent is set to true.

public RecipientContentProvider? RecipientContentProvider { get; set; }

Property Value

RecipientContentProvider

The content provider.

RecipientSpecificContent

Gets or sets a value indicating whether the messaging system should request body content per recipient or rely on the content in HtmlBody. Default is false. Setting this to true requires RecipientContentProvider to be supplied.

public bool RecipientSpecificContent { get; set; }

Property Value

bool

true if body content should be requested per recipient; otherwise, false.

RecipientsSource

Gets or sets the recipients source. This value indicated the source of the RecipientCollection that this Message is merged with by the MessagingHandler.

public string RecipientsSource { get; set; }

Property Value

string

The recipients source.

RequireUniqueRecipients

Gets or sets a value indicating whether require unique recipients. The RecipientKey is used to check Recipient uniqueness.

public bool RequireUniqueRecipients { get; set; }

Property Value

bool

true if recipients are required to be unique; otherwise, false. Default is true.

SenderEmail

Gets or sets the sender email.

public string? SenderEmail { get; set; }

Property Value

string

The sender email.

SenderName

Gets or sets the name of the sender.

public string? SenderName { get; set; }

Property Value

string

The name of the sender.

SentTime

Gets the sent time.

public MessageSentTimeInfo? SentTime { get; }

Property Value

MessageSentTimeInfo

The sent time.

Subject

Gets or sets the subject.

public string? Subject { get; set; }

Property Value

string

The subject.

Tags

Gets a dictionary containing all message body tags. These tags will be rendered into the message by the message merger. The tag values can contain the tags available in the Constants class. All tag constants start with "TAG_".

public Dictionary<string, object> Tags { get; }

Property Value

Dictionary<string, object>

Methods

GetMessageById(int)

Gets the message by id.

public static Message GetMessageById(int id)

Parameters

id int

The id.

Returns

Message

IsMessageOpenedByRecipient(int, int)

Gets a value indicating whether the Message with the given id has been opened by the Recipient with the given id.

public static bool IsMessageOpenedByRecipient(int messageId, int recipientId)

Parameters

messageId int

The message id.

recipientId int

The recipient id.

Returns

bool

MarkMessageAsOpenedByRecipient(string, int, int)

public static void MarkMessageAsOpenedByRecipient(string sessionId, int messageId, int recipientId)

Parameters

sessionId string
messageId int
recipientId int

Save()

Saves this instance.

public bool Save()

Returns

bool
To top