Class Ecommerce.Cart.SendingConfirmationMailArgs
- Namespace
- Dynamicweb.Ecommerce.Notifications
- Assembly
- Dynamicweb.Ecommerce.dll
Provides information about order and confirmation mail just before each individual Order Email is sent.
public class Ecommerce.Cart.SendingConfirmationMailArgs : NotificationArgs
- Inheritance
-
Ecommerce.Cart.SendingConfirmationMailArgs
- Inherited Members
Examples
using Dynamicweb.Core;
using Dynamicweb.Imaging;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.SendingConfirmationMail)]
public class EcomCartSendingConfirmationMailObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.SendingConfirmationMailArgs sendingConfirmationMailArgs = args as Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.SendingConfirmationMailArgs;
//**** Example for creating a PDF attachment for the order emails **** //
//EXAMPLE with inline markup
//Dynamicweb.Rendering.Template htmlForPdfTemplate = new Rendering.Template();
//tmlForPdfTemplate.Html = "<html><body><h1>Receipt</h1>@SomeRazorCode and regular Dynamicweb template language</body></html>";
//EXAMPLE with a razor template
//Load a template - with full html, including html, body, inline css etc. IE browser compatible
Dynamicweb.Rendering.Template htmlForPdfTemplate = new Rendering.Template("/eCom7/CartV2/Mail/pdfReceipt.cshtml");
//Create an order renderer instance
Dynamicweb.Ecommerce.Frontend.Renderer orderRenderer = new Frontend.Renderer();
//Render all order tags
orderRenderer.RenderOrder(sendingConfirmationMailArgs.Order, htmlForPdfTemplate);
//Add custom tags to the template
htmlForPdfTemplate.SetTag("RecipientEmail", sendingConfirmationMailArgs.Recipient.Address);
htmlForPdfTemplate.SetTag("ReceiptSubject", sendingConfirmationMailArgs.MailMessage.Subject);
string html = htmlForPdfTemplate.Output();
//Create a pdf from the template
string pathToOrderConfirmation = SystemInformation.MapPath($"/Files/System/OrderExport/Order{sendingConfirmationMailArgs.Order.Id}.pdf");
var settings = new PdfRendererSettings();
var renderer = new PdfRenderer(settings);
var bytes = renderer.RenderFromHtml(html);
System.IO.File.WriteAllBytes(pathToOrderConfirmation, bytes);
//Attach the pdf to the email
sendingConfirmationMailArgs.MailMessage.Attachments.Add(new System.Net.Mail.Attachment(pathToOrderConfirmation));
}
}
}
Remarks
The passed NotificationArgs is Ecommerce.Cart.SendingConfirmationMailArgs
Constructors
SendingConfirmationMailArgs(MailMessage, MailAddress, Order, ModuleSettings)
Initializes a new instance of the Ecommerce.Cart.SendingConfirmationMailArgs class.
public SendingConfirmationMailArgs(MailMessage mailMessage, MailAddress recipient, Order order, ModuleSettings cartModuleSettings)
Parameters
mailMessage
MailMessage- The mail message.
recipient
MailAddress- The recipient.
order
Order- The order.
cartModuleSettings
ModuleSettings- The module settings.
- See Also
Properties
CartModuleSettings
Gets the module settings.
public ModuleSettings CartModuleSettings { get; }
Property Value
- ModuleSettings
- The module settings.
- See Also
MailMessage
Gets the mail message.
public MailMessage MailMessage { get; }
Property Value
- MailMessage
- The mail message.
- See Also
Order
Gets the order.
public Order Order { get; }
Property Value
- Order
- The order.
- See Also
Recipient
Gets the recipient.
public MailAddress Recipient { get; }
Property Value
- MailAddress
- The recipient.
- See Also
SkipThisMail
Gets or sets a value indicating whether to skip the current email, preventing it from being sent.
public bool SkipThisMail { get; set; }
Property Value
- bool
true
if the mail is skipped; otherwise,false
.
- See Also
StopSendingMoreMails
Gets or sets a value indicating whether to skip the current email and all subsequent emails from being sent.
public bool StopSendingMoreMails { get; set; }
Property Value
- bool
true
if no more mails should be sent; otherwise,false
.
- See Also