Class EmailContext
- Namespace
- Kentico.EmailBuilder.Web.Mvc
- Assembly
- Kentico.Content.Web.Mvc.dll
Email context.
public sealed class EmailContext
- Inheritance
-
objectEmailContext
- Extension Methods
Remarks
Context is initialized for use only in an email builder.
Constructors
EmailContext()
Initializes an instance of EmailContext class.
[Obsolete("An empty constructor will be removed in the future and you will not be able to instantiate this class anymore.")]
public EmailContext()
Properties
BuilderMode
Email builder mode.
public EmailBuilderMode BuilderMode { get; init; }
Property Value
ContentItemId
Content item identifier.
public int ContentItemId { get; set; }
Property Value
- int
ContentTypeName
Email content type name.
public string ContentTypeName { get; init; }
Property Value
- string
EmailChannelId
Email channel identifier.
public int EmailChannelId { get; init; }
Property Value
- int
EmailFields
Fields of an email content type.
[Obsolete("Use the GetEmail<T> method to retrieve strongly-typed email data of a specified type.")]
public IDataContainer EmailFields { get; init; }
Property Value
Remarks
Accessing the values of fields with the following data types is not supported by this property: ContentItemReference, ContentItemAsset, Assets, WebPages, and Taxonomy. To retrieve email fields of any data type, use the GetEmail<T>(CancellationToken) method instead.
LanguageName
Current email language name.
public string LanguageName { get; init; }
Property Value
- string
Methods
GetEmail<T>(CancellationToken)
Asynchronously retrieves the email data of a specified type T
.
public Task<T> GetEmail<T>(CancellationToken cancellationToken = default) where T : class, IEmailFieldsSource
Parameters
cancellationToken
CancellationTokenCancellation token.
Returns
- Task<T>
Type Parameters
T
The specific type implementing IEmailFieldsSource that the email data is expected to be cast to.
Remarks
This method triggers the underlying data retrieval function by evaluating lazy email content.
Exceptions
- InvalidCastException
Thrown if the actual type of the retrieved email data (obtained via the factory function) cannot be cast to the specified type
T
.