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.
- Inheritance
-
Ecommerce.
Cart. Sending Confirmation Mail Args
- Inherited Members
Examples
using Dynamicweb.Core;
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 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");
using (var pdf = new Imaging.Pdf())
{
var bytes = pdf.ConvertHtml(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.
Constructors
SendingConfirmationMailArgs(MailMessage, MailAddress, Order, ModuleSettings)
Initializes a new instance of the Ecommerce.
public SendingConfirmationMailArgs(MailMessage mailMessage, MailAddress recipient, Order order, ModuleSettings cartModuleSettings)
Parameters
mailMessage
MailMessage The mail message.
recipient
MailAddress The recipient.
order
OrderThe order.
cartModuleSettings
ModuleSettings The module settings.
Properties
CartModuleSettings
Gets the module settings.
Property Value
- Module
Settings The module settings.
MailMessage
Gets the mail message.
Property Value
- Mail
Message The mail message.
Order
Gets the order.
Property Value
- Order
The order.
Recipient
Gets the recipient.
Property Value
- Mail
Address The recipient.
SkipThisMail
Gets or sets a value indicating whether to skip the current email, preventing it from being sent.
Property Value
- bool
true
if the mail is skipped; otherwise,false
.
StopSendingMoreMails
Gets or sets a value indicating whether to skip the current email and all subsequent emails from being sent.
Property Value
- bool
true
if no more mails should be sent; otherwise,false
.