SlideShare a Scribd company logo
1 of 8
MvcMailer
By Jax
Scaffold Your Mailer
PM> Scaffold Mailer.Razor UserMailer Welcome,PasswordReset
•
•
•
•
•

MailersIUserMailer.cs
MailersUserMailer.cs
ViewsUserMailer_Layout.cshtml
ViewsUserMailerWelcome.cshtml
ViewsUserMailerPasswordReset.cshtml
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;
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> Scaffold Mailer.Razor UserMailer Welcome,GoodBye
# This will produce Aspx views
PM> Scaffold Mailer.Aspx UserMailer Welcome,GoodBye
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
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);
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;
}

More Related Content

Similar to Mvc Mailer

Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingPatrick Reagan
 
Training in Asp.net mvc3 platform-apextgi,noida
Training in Asp.net mvc3 platform-apextgi,noidaTraining in Asp.net mvc3 platform-apextgi,noida
Training in Asp.net mvc3 platform-apextgi,noidaprav068
 
Rest with grails 3
Rest with grails 3Rest with grails 3
Rest with grails 3Jenn Strater
 
PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)TaiShunHuang
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::ManagerJay Shirley
 
Microsoft Web Matrix
Microsoft Web MatrixMicrosoft Web Matrix
Microsoft Web MatrixSaurabh Moody
 
WebSockets Jump Start
WebSockets Jump StartWebSockets Jump Start
WebSockets Jump StartHaim Michael
 

Similar to Mvc Mailer (10)

PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Training in Asp.net mvc3 platform-apextgi,noida
Training in Asp.net mvc3 platform-apextgi,noidaTraining in Asp.net mvc3 platform-apextgi,noida
Training in Asp.net mvc3 platform-apextgi,noida
 
Rest with grails 3
Rest with grails 3Rest with grails 3
Rest with grails 3
 
PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
PHP with MYSQL
PHP with MYSQLPHP with MYSQL
PHP with MYSQL
 
Microsoft Web Matrix
Microsoft Web MatrixMicrosoft Web Matrix
Microsoft Web Matrix
 
WebSockets Jump Start
WebSockets Jump StartWebSockets Jump Start
WebSockets Jump Start
 

More from LearningTech

More from LearningTech (20)

vim
vimvim
vim
 
PostCss
PostCssPostCss
PostCss
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 

Recently uploaded

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

Mvc Mailer

  • 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; }