Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,463
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. MvcMailer By Jax
  • 2. Scaffold Your Mailer PM> Scaffold Mailer.Razor UserMailer Welcome,PasswordReset • • • • • MailersIUserMailer.cs MailersUserMailer.cs ViewsUserMailer_Layout.cshtml ViewsUserMailerWelcome.cshtml ViewsUserMailerPasswordReset.cshtml
  • 3. Pass Data to Mailer Views ViewBag.Name = "Sohan"; ViewBag.Comment = myComment; ViewData["Name"] = "Sohan"; ViewData["Comment"] = myComment; var comment = new Comment { To = you, Message = "Great Work!" }; ViewData = new ViewDataDictionary(comment); var comment = new Comment { To = you, Message = "Great Work!" }; ViewData.Model = comment;
  • 4. Send var userMailer = new UserMailer(); userMailer.Welcome().Send(); userMailer.Welcome().SendAsync();
  • 5. Other Options # No Interface PM> Scaffold Mailer.Razor MyMailer Welcome -NoInterface # This will produce Razor views PM> Scaffold Mailer.Razor UserMailer Welcome,GoodBye # This will produce Aspx views PM> Scaffold Mailer.Aspx UserMailer Welcome,GoodBye
  • 6. Send Multi-part Emails PM> scaffold Mailer MyMailer Hello –WithText • • • • • • MailersIMyMailer.cs MailersMyMailer.cs ViewsMyMailer_Layout.cshtml ViewsMyMailerHello.cshtml ViewsMyMailer_Layout.text.cshtml ViewsMyMailerHello.text.cshtml
  • 7. Embed Image or Linked Resource Inside Email In Your View @using Mvc.Mailer @Html.InlineImage("logo", "Company Logo") ### public static IHtmlString InlineImage(this HtmlHelper htmlHelper, string contentId, string alt = ""); In Your Mailer var resources = new Dictionary<string, string>(); resources["logo"] = @"D:001.png"; PopulateBody(mailMessage, "WelcomeMessage", resources);
  • 8. My Using private MvcMailMessage getMailMessage(string viewName, object vm = null) { ViewData.Model = vm; MvcMailMessage message = Populate(x => { x.ViewName = viewName; }); message.Subject = Regex.Match( message.Body, @"(?<=<title[^>]*>)([^<]*)(?=</title>)", RegexOptions.IgnoreCase ).Value.Trim(); return message; } public virtual MvcMailMessage MemberEnabledNotice(MemberViewModel vm) { MvcMailMessage message = getMailMessage("MemberEnabledNotice", vm); /*To Member*/ message.To.Add(vm.Email); return message; }