2

I have a windows service that is supposed to send e-mails periodically.

Next to the windows service project there is an MVC 3 project that is sending e-mails with MvcMailer (beautifully).

I want to use the same engine to send e-mails for the windows service.

How should I do it?

Import the MVC binaries and create one controller and new views for this purpose? Will it work?

Saving it in the database and requesting my web project to send the e-mail might not be the best solution because the information is the result of a query and is too big to be sent in the request.

The only other option I see is to simply request the web project to do all the work but this way it wouldn't be beneficial to place the windows service in another service to save the site application resources. How would you do it?

Fabio Milheiro
  • 8,100
  • 17
  • 57
  • 96

3 Answers3

4

As an alternative to MVC Mail, ActionMailer.NET can now be used stand-alone outside of MVC.

The details are covered here

http://geeksharp.com/2011/07/06/actionmailer-0-6-released/

Eric J.
  • 147,927
  • 63
  • 340
  • 553
0

Why do you think the query to send to mvcmailer us too large? If you have the mailer MVC project already working and exposed via a restful URL, that becomes your email service and simply call it as a web request from your service.

You can get around size constraints in your request That shouldnt be an issue.

Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71
0

I would argue that calling a mvc mailer from the service might be an overkill. If the mvc project is supposed to expose sending the email API for all of your other solutions, then building a REST api might make sense. However, if you just want to bring the functionality of the action method to the windows service, then i would choose an in-process functional component. If you can refactor the logic of the mvcmailer action method into another assembly why not just do that and then include that assemlby as a depedency in your windows service solution. If you can provide the over all purpose of the mailer and how it's used in the web scenario, it may help us to provide a better architecture.

Roman
  • 1,177
  • 1
  • 17
  • 25