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

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Recently uploaded (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

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