I've just finished a project and had some spare time. The domino website that we have been running for a particular client needed some new content and a email mail-out send to all the website members to let them know. So I started having a look at how I should do that and in 30 minutes I'd finished.
The website already have functionality to send confirmation emails, but mail-out functionality was not included in the original scope.
So how did I manage that ? The architecture of the website is built using xml templates for web content. Early on in the development, I'd decided that email templates should also use XML. After all the the mime messages that we need to generate are pretty much XML and I could extend the XMLRenderFactory to also do the email template to mime rendering.
So I started by creating the new email mailout template like the confirmation emails. The example below has been change slightly. note the <scm:xxx> nodes.
<scm:email>
<head>
<style type="text/css">
....
</style>
</head>
<table border="0" width="499px" cellspacing="0" cellpadding="0">
<tr><td bgcolor="#990033">
<img src="http://www.somewebsite/x.nsf/mailbanner.gif" width="500px" height="50px"/>
</td></tr>
<tr><td bgcolor="#990033" color="white"><h1>New Resources are available online</h1></td></tr>
<tr><td>
<p style="font-size:10px; color:#B10034;font-family:verdana">Dear
<scm:profile key="firstname"/> <scm:profile key="surname"/>
new resources are available on-line now.<br/><br/>
</p>
</td></tr>
<tr><td bgcolor="#990033">
<p class="footer"><img src="http://www.somewebsite/x.nsf/footerlogo.jpg"/></p>
</td></tr>
</table>
</scm:email>
I looked at the shared action that was currently used to send an registration emails.
Set confirmMessage = New SCMTemplateMailMessage(session,note)
confirmMessage.SendTo = note.email(0)
Call confirmMessage.SendMessage("register_confirm")
note.registration_sent = Now
Call note.Save(True,False)
I created a new one, and change two lines and added it to the form.
Set confirmMessage = New SCMTemplateMailMessage(session,note)
confirmMessage.SendTo = note.email(0)
Call confirmMessage.SendMessage("mailout_series2")
note.mailout_2 = Now
Call note.Save(True,False)
I ran it against a profile of a test member. Then I needed the ability to send bulk mail-outs so I wrapped the whole thing into an agent to run against selected members in the database.
Done.
I couldn't have done this if the architecture of the application hadn't been using an Object Oriented approach, abstracting the email message into a SCMTemplateMailMessage provided flexibility in reusing it for something that was outside the scope of the original design.
If someone questions the value of using OO techniques in Domino or Lotus Notes send them here.