Sana Assistant (online)
Table of Contents

Extension.Api.MailManager reference

Every extension in Sana has access to mail sending functionality via Api.MailManager. This property holds an instance of MailManager type which serves as an entry point to mailing functionality.

Methods

MailManager class diagram

SendEmail(IEnumerable<string> to, string templateName, NameValueCollection replacementTags, IDictionary<string, object> viewData = null, IEnumerable<MailAttachment> attachments = null)

Sends an email in the selected language of the current webstore user based on the webstore mail template. Mail template must be added to the MailTemplates\MailTemplates.resx file. replacementTags and viewData parameters give the ability to manage email content. replacementTags will be inserted at the appropriate positions in the resource file. If the mail should have a custom view, then it should be added under Views\MailTemplates folder. The processed mail template will be passed to the custom view in the model. Data models for partial views should be passed using viewData parameter. viewData is not used if the mail does not have a custom view. attachments parameter gives possibility to provide file attachments to mail.

var replacementTags = new NameValueCollection();
replacementTags.Add("LINK", "example.com");
Api.MailManager.SendEmail(new[] { some@sana-commerce.com }, "FollowEmail", replacementTags)

SendAdminEmail(IEnumerable<string> to, string templateName, NameValueCollection replacementTags, IDictionary<string, object> viewData = null, IEnumerable<MailAttachment> attachments = null)

Sends an email in the admin language based on the admin mail template. Mail template must be added to the AdminMailTemplates\AdminMailTemplates.resx file. replacementTags and viewData parameters give the ability to manage email content. replacementTags will be inserted at the appropriate positions in the resource file. If the mail should have a custom view, then it should be added under Views\AdminMailTemplates folder. The processed mail template will be passed to the custom view in the model. Data models for partial views should be passed using viewData parameter. viewData is not used if the mail does not have a custom view. attachments parameter gives possibility to provide file attachments to mail.

var replacementTags = new NameValueCollection();
replacementTags.Add("LINK", "example.com");
Api.MailManager.SendEmail(new[] { some@sana-commerce.com }, "FollowEmail", replacementTags)

SendAdminEmailToCustomerService(string templateName, NameValueCollection replacementTags, IDictionary<string, object> viewData = null, IEnumerable<MailAttachment> attachments = null)

Sends an email to the customer service email addresses in the admin language based on the admin mail template. Mail template must be added to the AdminMailTemplates\AdminMailTemplates.resx file. replacementTags and viewData parameters give the ability to manage email content. replacementTags will be inserted at the appropriate positions in the resource file. If the mail should have a custom view, then it should be added under Views\AdminMailTemplates folder. The processed mail template will be passed to the custom view in the model. Data models for partial views should be passed using viewData parameter. viewData is not used if the mail does not have a custom view. attachments parameter gives possibility to provide file attachments to mail.

See also