Click or drag to resize

EcommerceCartSendingConfirmationMailArgs Class

Provides information about order and confirmation mail just before each individual Order Email is sent.
Inheritance Hierarchy
SystemObject
  Dynamicweb.Extensibility.NotificationsNotificationArgs
    Dynamicweb.Ecommerce.NotificationsEcommerceCartSendingConfirmationMailArgs

Namespace:  Dynamicweb.Ecommerce.Notifications
Assembly:  Dynamicweb.Ecommerce (in Dynamicweb.Ecommerce.dll) Version: 1.10.0
Syntax
public class SendingConfirmationMailArgs : NotificationArgs

The EcommerceCartSendingConfirmationMailArgs type exposes the following members.

Constructors
  NameDescription
Public methodEcommerceCartSendingConfirmationMailArgs
Initializes a new instance of the EcommerceCartSendingConfirmationMailArgs class.
Top
Properties
  NameDescription
Public propertyCartModuleSettings
Gets the module settings.
Public propertyMailMessage
Gets the mail message.
Public propertyOrder
Gets the order.
Public propertyRecipient
Gets the recipient.
Public propertySkipThisMail
Gets or sets a value indicating whether to skip the current email, preventing it from being sent.
Public propertyStopSendingMoreMails
Gets or sets a value indicating whether to skip the current email and all subsequent emails from being sent.
Top
Remarks
The passed NotificationArgs is EcommerceCartSendingConfirmationMailArgs
Examples
C#
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 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");

            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));
        }
    }
}
See Also