Your SlideShare is downloading. ×
0
MvcMailer
By Jax
Scaffold Your Mailer
PM> Scaffold Mailer.Razor UserMailer Welcome,PasswordReset
•
•
•
•
•

MailersIUserMailer.cs
MailersUs...
Pass Data to Mailer Views
ViewBag.Name = "Sohan";
ViewBag.Comment = myComment;
ViewData["Name"] = "Sohan";
ViewData["Comme...
Send
var userMailer = new UserMailer();
userMailer.Welcome().Send();
userMailer.Welcome().SendAsync();
Other Options
# No Interface
PM> Scaffold Mailer.Razor MyMailer Welcome -NoInterface
# This will produce Razor views
PM> S...
Send Multi-part Emails
PM> scaffold Mailer MyMailer Hello –WithText
•
•
•
•
•
•

MailersIMyMailer.cs
MailersMyMailer.cs
Vi...
Embed Image or Linked Resource Inside Email
In Your View
@using Mvc.Mailer
@Html.InlineImage("logo", "Company Logo")
### p...
My Using
private MvcMailMessage getMailMessage(string viewName, object vm = null)
{
ViewData.Model = vm;
MvcMailMessage me...
Upcoming SlideShare
Loading in...5
×

Mvc Mailer

2,619

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,619
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Mvc Mailer"

  1. 1. MvcMailer By Jax
  2. 2. Scaffold Your Mailer PM> Scaffold Mailer.Razor UserMailer Welcome,PasswordReset • • • • • MailersIUserMailer.cs MailersUserMailer.cs ViewsUserMailer_Layout.cshtml ViewsUserMailerWelcome.cshtml ViewsUserMailerPasswordReset.cshtml
  3. 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. 4. Send var userMailer = new UserMailer(); userMailer.Welcome().Send(); userMailer.Welcome().SendAsync();
  5. 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. 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. 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. 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; }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×