0

I'm writing an .net 4.5 app to be deployed to Azure. I'd like to have a worker role which periodically checks an email address for new messages, copies the attachments off any emails, and dumps them to blob storage.

I see lots of stuff on how to send email, but not how to actually monitor an email account and process messages.

EDIT: The blobs are files which will then be displayed to the user

Scott Decker
  • 4,229
  • 7
  • 24
  • 39
  • Realize that the ASP.Net pipeline is executed per request. This means that ASP.Net cannot run *scheduled* tasks. Instead you should write [a different type of Azure application](http://stackoverflow.com/questions/7794572/windows-service-to-azure) that can run as you see fit. – Erik Philips Aug 31 '14 at 02:26
  • @ErikPhilips, I disagree. We have several architectures that use worker roles to implement scheduled tasks. In addition, Azure offers its own scheduler which can call a controller action to run a task on a schedule. Maybe I'm misunderstanding you? – Scott Decker Aug 31 '14 at 02:29
  • 1
    @scottndecker - worker roles are not web apps. What is the point of writing an MVC app if it's not doing anything web related? – Erik Funkenbusch Aug 31 '14 at 02:35
  • The link I provided talks about Windows Services and WorkerRole. – Erik Philips Aug 31 '14 at 02:36
  • @ErikFunkenbusch, agreed on the point of MVC app. See edits. – Scott Decker Aug 31 '14 at 02:42
  • @scottndecker - so the mvc part is doing nothing email related, it's just displaying blobs to the user. that seems simple enough, what's the problem with that? – Erik Funkenbusch Aug 31 '14 at 02:52
  • @ErikFunkenbusch, absolutely. Getting blobs and showing them is cake. The tough part is creating a worker role that will monitor an email account and pull attachments from emails into blob storage. – Scott Decker Aug 31 '14 at 02:59
  • @scottndecker - Then I would suggest that since your real problem has nothing to do with MVC, you de-emphasis that (in fact, remove it entirely) and focus instead on the root of your problem, .net and email processing, perhaps with a azure worker role bent. As it is, the mvc tags and title just confuse things. – Erik Funkenbusch Aug 31 '14 at 04:08

1 Answers1

0

There are two methods you can employ to monitor an email account. Either

  1. poll the account using POP3 or IMAP - slightly yuk
  2. use a more proactive approach such as IMAP Idle (more information) which can receive new message notifications client-side, assuming the mail server supports this.

A quick hunt around NuGet will turn up a variety of libraries that support the above techniques, although to get you started I've found S22.Imap more than adequate and has sufficient examples.

Enjoy

SeanCocteau
  • 1,838
  • 19
  • 25