0

I need to send like 100 000 mails, so I need my process to be efficient.

We are using MvcMailer because the enables us to use Razor as the template engine.

My problem : the resulting email is in 2 part:

  • A common part for everyone
  • A custom part for each recipients

Because there is a custom part I have to create a new mail for everyone. But MvcMailer is running the view engine for every mail, so the common part is rendered 100 000, and that is not acceptable.

My only idea so far :

  • use the EmailBody method for rendering the common part at the very beginning of my process (in this common part there'll be something like "{USER-CONTENT}")

    string commonContent = mailer.EmailBody("Common");

  • Populate my mail body with only the user content and do

    myMail.Body = commonContent.Replace("{USER-CONTENT}",myMail.Body)

But it's still a dirty solution : creating my own template language inside Razor.

Do you have a better idea ?

4

0 回答 0