Dashboard > MonoRail > Home > Sending Email With RenderViewAndSend
Sending Email With RenderViewAndSend
Added by Dusty Candland, last edited by Dusty Candland on Apr 05, 2008
Labels: 
(None)


Templates

When sending an email using RenderMessageAndSend the following will be parsed for the message and removed what's left is sent as the body.

from: name <address> or address
to: address,address
cc: address,address
bcc: address,address
subject: value
X-header: value
body text

If the body text contains '<html>' it will be sent as html.

By default layouts will not be applied. It looks for views stored in Common if the view name starts with a /. Otherwise it looks for views in the Mail folder.

  • /MailTemplate.brail should be stored in views/common/MailTemplate.brail
  • MailTemplate.brail should be stored in views/mail/MailTemplate.brail

Testing

The test support doesn't currently render the message, but you can check for the number of message sent and the template name and properties.

Assert.That(MessagesSent.Length, Is.EqualTo(2));
Assert.That(RenderedEmailTemplates[0].Name, Is.EqualTo("MailTemplate"));
Assert.That(RenderedEmailTemplates[0].Parameters["to"], Is.EqualTo(emails[0]));

In the MessageSent Collection all the messages are hard coded as

new Message("from", "to", "subject", "body");

Site running on a free Atlassian Confluence Community License granted to Castle Project. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators