c a n d l a n d . n e t

Send Email using RenderViewAndSend on Monorail

Dusty Candland | |

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 ‘’ 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

  •   <li id="zt.p">
        MailTemplate.brail should be stored in views/mail/MailTemplate.brail<br id="gemr" />
      </li></ul> 
      
      <h3>
        <span id="j8r8">Testing</span><br id="txfs" />
      </h3>
      
      <p>
        The test support doesn&rsquo;t currently render the message, but you can check for the number of message sent and the template name and properties.<br id="m62q" /><span id="ctl00_ContentPlaceHolder1_output"></p> 
        
        <pre id="urhn" class="csharpcode">Assert.That(MessagesSent.Length, Is.EqualTo(2));<br id="xujk" />Assert.That(RenderedEmailTemplates[0].Name, Is.EqualTo(<span id="pc-e" class="str">&ldquo;MailTemplate&rdquo;</span>));<br id="xi2i" />Assert.That(RenderedEmailTemplates[0].Parameters[<span id="wqoj" class="str">&ldquo;to&rdquo;</span>], Is.EqualTo(emails[0]));</pre>
        
        <p>
          </span>In the MessageSent Collection all the messages are hard coded as <font id="w0gt" color="#1000a0"><br style="background-color: rgb(0, 0, 0);" id="jw.p" /><font id="idsz" color="#000000"><span id="kj1:" style="background-color: rgb(255, 255, 255);"></span></font></font><span id="ctl00_ContentPlaceHolder1_output"></p> 
          
          <pre id="kopx" class="csharpcode"><span id="fwt6" class="kwrd">new</span> Message(<span id="dxea" class="str">&ldquo;from&rdquo;</span>, <span id="ft8i" class="str">&ldquo;to&rdquo;</span>, <span id="ducq" class="str">&ldquo;subject&rdquo;</span>, <span id="r:io" class="str">&ldquo;body&rdquo;</span>);</pre>
          
          <p>
            </span><font id="w0gt" color="#1000a0"><font id="idsz" color="#000000"><span id="kj1:" style="background-color: rgb(255, 255, 255);"></span></font></font><font id="q3jw" color="#000000"><span id="mbjr" style="background-color: rgb(255, 255, 255);"></span></font><a title="Also added to using.castleproject.org Sending Email With RenderViewAndSend" href="http://using.castleproject.org/display/MR/Sending+Email+With+RenderViewAndSend" id="p0fd">Also added to using.castleproject.org Sending Email With RenderViewAndSend</a> <br id="cl-3" /><br id="q3j4" /><br id="obfa" /><br id="sn0." />
          </p></p>
    

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: