Class Recipient
- Namespace
- Dynamicweb.Mailing
- Assembly
- Dynamicweb.Core.dll
A recipient object used for EmailMessaging.
- Inheritance
-
Recipient
- Inherited Members
Examples
using System;
namespace Dynamicweb.Mailing.Examples;
public static class MessageRecipientSendingSample
{
public static void SendMessage()
{
//Create a recipient collection and fill it with 100 recipients.
var recipientCollection = new RecipientCollection();
for (int i = 0; i < 100; i++)
{
var recipient = new Recipient { RecipientKey = "Key" };
recipient.Name = "Test" + i;
recipient.EmailAddress = $"test{i}@testdomain.tld";
recipientCollection.Add(recipient);
}
//Create a message that will be sent.
var message = new Message();
message.Subject = "This is a test email";
message.HtmlBody = $"<h1>Hello <!--@{Constants.TagRecipientName}--></h1><br /><p>This is a test</p>";
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 NotSupportedException("Sending could not be started");
}
}
Constructors
Recipient()
Properties
Content
Gets or sets the content. This property is not persisted to database.
Property Value
- string
The content.
EmailAddress
Gets or sets the email address.
Property Value
- string
The email address.
ErrorMessage
Gets the error message if an error has occurred while sending to this Recipient.
Property Value
- string
The error message.
ErrorTime
Gets the error time if an error has occurred.
If no error has occurred, Min
Property Value
- Date
Time The error time.
HasLinkClicks
Gets a value indicating whether this instance has link clicks.
Property Value
- bool
true
if this instance has link clicks; otherwise,false
.
Id
Gets the id.
Property Value
IsMessageSent
Property Value
- bool
true
if this instance is message sent; otherwise,false
.
IsNew
Gets a value indicating whether this instance is new.
Property Value
- bool
true
if this instance is new; otherwise,false
.
LinkClicks
Gets the link clicks that this Recipient has performed.
Property Value
- IEnumerable<Link
Click > The link clicks.
MessageId
Gets the message id.
Property Value
Name
Gets or sets the name.
Property Value
- string
The name.
RecipientKey
Gets or sets the recipient key.
If no recipient key is provided when the recipient is saved, the Email
Property Value
- string
The recipient key.
Secret
Gets the secret value for this recipient. The secret value is used to check validity of recipient.
Property Value
- string
The secret.
SentTime
Gets the Date
Property Value
- Date
Time The sent time.
TagValueCollection
Gets or sets the tag value collection.
Property Value
- Dictionary<string, object>
The tag value collection.
Methods
GetIncompleteRecipientsByMessageId(int)
Gets the incomplete recipients by message id.
Parameters
messageId
intThe message id.
Returns
GetLatestSentTimeByRecipientKeys(IEnumerable<string>)
Gets the latest sent time by recipient keys. If a recipient key has not beed sent to previously, the entry will not recipient key will not appear in the return dictionary.
public static IDictionary<string, DateTime> GetLatestSentTimeByRecipientKeys(IEnumerable<string> keys)
Parameters
keys
IEnumerable<string>The keys.
Returns
GetRecipientById(int)
Gets the recipient by id.
Parameters
id
intThe id.
Returns
GetRecipientKeysByMessageId(int)
Gets the recipient keys by message id.
Parameters
messageId
intThe message id.
Returns
GetRecipientKeysWithLatestSentTimeByMessageId(int)
Gets the recipient keys with latest sent time by message id.
public static IDictionary<string, DateTime> GetRecipientKeysWithLatestSentTimeByMessageId(int messageId)
Parameters
messageId
intThe message id.
Returns
GetRecipientsByMessageId(int)
Gets the recipients by message id.
Parameters
messageId
intThe message id.
Returns
GetRecipientsByUser(string)
Parameters
userKey
string
Returns
GetRecipientsByUser(string, int)
Parameters
Returns
HasIncompleteRecipientsByMessageId(int)
Determines whether there are incomplete recipients by message id.
Parameters
messageId
intThe message id.
Returns
LogError(Exception)
Logs the error.
Parameters
errorException
ExceptionThe error exception.
LogError(string)
Logs the error.
Parameters
errorMessage
stringThe error message.
Save()
Saves this instance.
Returns
SetMessageSent()
Sets the message sent.
WriteMessageSentFromLog(int)
Parameters
messageId
int