Created
April 27, 2012 12:28
-
-
Save AymericG/2508833 to your computer and use it in GitHub Desktop.
How to use MvcMailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mailer.Invitation(emailAddresses.ToArray(), LoggedInUser.Name, inviteMessage).Send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ApplicationController : Controller | |
{ | |
private UserMailer _mailer = new UserMailer(); | |
public UserMailer Mailer | |
{ | |
get { return _mailer; } | |
set { _mailer = value; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>@ViewBag.Title</h1> | |
<p> | |
<b>@ViewBag.FromUserName</b> sent you this message: | |
</p> | |
<p>"@ViewBag.InviteMessage"</p> | |
<p> | |
WEEK PLAN is a free weekly planner inspired by the book "Seven Habits of Highly Effective People". | |
</p> | |
<p> | |
<a href="http://weekplan.net/?invited=1">Check WEEK PLAN out</a>. | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= @ViewBag.Title = | |
@ViewBag.FromUserName sent you this message: | |
"@ViewBag.InviteMessage" | |
WEEK PLAN is a free weekly planner inspired by the book "Seven Habits of Highly Effective People". | |
Check WEEK PLAN out: http://weekplan.net/?invited=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install-package MvcMailer | |
Scaffold Mailer UserMailer Invitation,NewPassword,NewComment –WithText –NoInterface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual MailMessage Invitation(string[] tos, string fromUserName, string inviteMessage) | |
{ | |
var message = new MailMessage | |
{ | |
Subject = fromUserName + " wants to help you be more effective" | |
}; | |
foreach (var to in tos) | |
message.Bcc.Add(to); | |
// Pass data to the view | |
ViewBag.Title = "You have received an invitation to use WEEK PLAN"; | |
ViewBag.FromUserName = fromUserName; | |
ViewBag.InviteMessage = inviteMessage; | |
// MVCMailer magic | |
PopulateBody(message, viewName: "Invitation"); | |
return message; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.net> | |
<mailSettings> | |
<smtp from="hello@wiselabs.net" deliveryMethod="SpecifiedPickupDirectory"> | |
<network host="localhost" /> | |
<specifiedPickupDirectory pickupDirectoryLocation="C:\Temp\SMTP Drop"/> | |
</smtp> | |
</mailSettings> | |
</system.net> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.net> | |
<mailSettings xdt:Transform="Replace"> | |
<smtp from="hello@wiselabs.net"> | |
<network enableSsl="true" host="smtp.sendgrid.net" port="587" userName="UserName" password="********" /> | |
</smtp> | |
</mailSettings> | |
</system.net> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment