Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat would be considered the best way to architect sending email from a C# web application?
    primarykey
    data
    text
    <p>I am working on a web application that will be going live soon, and I am now trying to figure out the best way for handling sending email from the application. I understand completely HOW to send email from the application using the MailMessage and SmtpClient classes, however my question is from a different angle. My main purpose at my job before this project was support of old applications that had been developed before my time. In these applications, when they needed to send email, they hard coded any of the messages into the actual message with all of the HTML tags embeded directly into the C# code.</p> <p>The application that I am working on will have a template for the emails to be sent in, as a sort of styling container, and the different messages will be embeded into the main content div's of the template. I would like to avoid hardcoding these templates in this application, so I have been trying to figure out the best way to layout my project. I have thought of using a t4 template, and reading the different t4's into the application and applying a String.Format with the specified parameters to add names/emails to the messages to be sent. However, I am not sure this is the best way to do it.</p> <p>My other idea was to define a class for each type of message, however this would end up hardcoding messages again, which as I said I don't want to do.</p> <p>My question is, how have you approached this in the past? What worked, and what didn't and for what reasons? I have looked all over online, but either the only content out there is on HOW to send the message, or I have not used the right Google power words.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CODo you have access to a database? You could store each type of message, the recipients, subject, body, etc in a database and build a simple maintenance routine on top of it. You can also enter various tags inside the email body to act as placeholders for other text (like a user's name). I've done this before and it works reasonably well.
      singulars
    2. COThe application does have a database, and this is one of the things that I had actually considered doing. I was kind of wary about doing this at first, as I wasn't sure that the messages should be stored in the database, but it is definetly a pro that the message can be updated at any time. The recipients are also currently stored in the database as well. Thanks for the input, and I will definetly consider it more now that I know someone else has done it well. I still wonder though whether or not there is a better way.
      singulars
    3. COWhat have you tried on your own thus far in regards to chat code do you have so that someone on line here can see and possibly help you..? Depends on what you are really looking for sending email is not a difficult task since .NET provides you with a lot of options using System.Net.Mail or via Web Application using System.Web.Mail there a a lot of previous examples as well that you can search and research on this site or checkout codeproject.com lots of great examples
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload