I have an alert system in my application where we save users messages to one another in our SQL database. Now our users would like us to start emailing notifications for those messages.
I have a Message object and MessageRecipient objects and a collection to hold them. These are CSLA objects that I use to create a new message, set subject, body, and other properties and then add recipients to the MessageRecipients child collection. All of our data is stored in sql database and then we have other methods that show these messages on our users Alert pages.
So now I need to have some kind of .SendEmailNotifications method that is going to use the System.Net.Mail to take these properties and recipients and send the emails. I'm trying to decide where to put this. Whether I should add a static method to the Message class, Message.SendEmailNotifications that checks the recipients properties to see if they recieve email alerts or not and then sends the emails. Or, should I create some kind of Mailer object that has properties Subject, Body, etc. and then has .AddEmailRecipient(userID) method to add email reciepients, then finally a .SendEmail method to send it all.
So should I keep it in my existing Message object or create a seperate Mailer object? What do you think?
I've previously created a seperate class library for this sort of thing so it can be re-used across many projects.
So I have my wrapper class around the System.Net.Mail and then versions of SendMessage methods that can take a simple string, or message object, etc.
Copyright (c) Marimer LLC