Class Recipient
- Namespace
- Dynamicweb.Mailing
- Assembly
- Dynamicweb.Mailing.dll
A recipient object used for EmailMessaging.
public class Recipient
- Inheritance
-
Recipient
- 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
Recipient()
public Recipient()
Properties
Content
Gets or sets the content. This property is not persisted to database.
public string Content { get; set; }
Property Value
- string
- The content.
EmailAddress
Gets or sets the email address.
public string EmailAddress { get; set; }
Property Value
- string
- The email address.
ErrorMessage
Gets the error message if an error has occurred while sending to this Recipient.
public string ErrorMessage { get; }
Property Value
- string
- The error message.
ErrorTime
Gets the error time if an error has occurred.
If no error has occurred, MinValue is returned.
public DateTime ErrorTime { get; set; }
Property Value
- DateTime
- The error time.
HasLinkClicks
Gets a value indicating whether this instance has link clicks.
public bool HasLinkClicks { get; }
Property Value
- bool
true
if this instance has link clicks; otherwise,false
.
Id
Gets the id.
public int Id { get; set; }
Property Value
IsMessageSent
public bool IsMessageSent { get; }
Property Value
- bool
true
if this instance is message sent; otherwise,false
.
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
.
LinkClicks
Gets the link clicks that this Recipient has performed.
public IEnumerable<LinkClick> LinkClicks { get; }
Property Value
- IEnumerable<LinkClick>
- The link clicks.
MessageId
Gets the message id.
public int MessageId { get; set; }
Property Value
Name
Gets or sets the name.
public string Name { get; set; }
Property Value
- string
- The name.
RecipientKey
Gets or sets the recipient key.
If no recipient key is provided when the recipient is saved, the EmailAddress is used.
public string RecipientKey { get; set; }
Property Value
- string
- The recipient key.
Secret
Gets the secret value for this recipient. The secret value is used to check validity of recipient.
public string Secret { get; }
Property Value
- string
- The secret.
SentTime
Gets the DateTime when the message was sent.
If the Message to which this Recipient belongs has not sent to this yet, MinValue is returned.
Use IsMessageSent property to determine whether the Message to this Recipient has been sent.
public DateTime SentTime { get; }
Property Value
- DateTime
- The sent time.
TagValueCollection
Gets or sets the tag value collection.
public Dictionary<string, object> TagValueCollection { get; }
Property Value
- Dictionary<string, object>
- The tag value collection.
Methods
GetIncompleteRecipientsByMessageId(int)
Gets the incomplete recipients by message id.
public static RecipientCollection GetIncompleteRecipientsByMessageId(int messageId)
Parameters
messageId
int- The 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.
public static Recipient GetRecipientById(int id)
Parameters
id
int- The id.
Returns
GetRecipientKeysByMessageId(int)
Gets the recipient keys by message id.
public static IList<string> GetRecipientKeysByMessageId(int messageId)
Parameters
messageId
int- The 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
int- The message id.
Returns
GetRecipientsByMessageId(int)
Gets the recipients by message id.
public static RecipientCollection GetRecipientsByMessageId(int messageId)
Parameters
messageId
int- The message id.
Returns
GetRecipientsByUser(string)
public static RecipientCollection GetRecipientsByUser(string userKey)
Parameters
userKey
string
Returns
GetRecipientsByUser(string, int)
public static RecipientCollection GetRecipientsByUser(string userKey, int messageId)
Parameters
Returns
HasIncompleteRecipientsByMessageId(int)
Determines whether there are incomplete recipients by message id.
public static bool HasIncompleteRecipientsByMessageId(int messageId)
Parameters
messageId
int- The message id.
Returns
LogError(Exception)
Logs the error.
public void LogError(Exception errorException)
Parameters
errorException
Exception- The error exception.
LogError(string)
Logs the error.
public void LogError(string errorMessage)
Parameters
errorMessage
string- The error message.
Save()
Saves this instance.
public bool Save()
Returns
SetMessageSent()
Sets the message sent.
public void SetMessageSent()
WriteMessageSentFromLog(int)
public static void WriteMessageSentFromLog(int messageId)
Parameters
messageId
int