Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gimped sample of sending an email with fubu
public class SendEmailNowBehavior<TResponse> : IActionBehavior
where TResponse : RenderEmailBase
private readonly IOutputWriter _outputWriter;
private readonly IFubuRequest _fubuRequest;
private readonly IMailer _mailer;
public SendEmailNowBehavior(IOutputWriter outputWriter, IFubuRequest fubuRequest, IMailer mailer)
_outputWriter = outputWriter;
_fubuRequest = fubuRequest;
_mailer = mailer;
public IActionBehavior InsideBehavior { get; set; }
public void Invoke()
if(InsideBehavior == null)
throw new InvalidOperationException("To send the email there must be an output behavior to render the spark view.");
_fubuRequest.Set(new CurrentMimeType("*/*", "text/html"));
var response = _fubuRequest.Get<TResponse>();
if (response == null)
response.Body = _outputWriter.Record(() => InsideBehavior.Invoke()).GetText();
_mailer.SendEmail(response.Subject, response.ToEmailAddress, response.Body);
public void InvokePartial()
throw new System.NotImplementedException();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment