0

I have recently been working on an ASP.Net MVC project where I need to trigger an action when a new email comes to my Gmail (or any other email service provider) email server.

The action I need to trigger is already implemented as a class method. And I have already made up a solution which will check for new emails (in the mail server using the Google APIs) when a user calls the method. But I want this to 'trigger' automatically.

Is there an asynchronous event handler where I can constantly check for new emails in the background and the method gets triggered when a new email pops up (e.g. SignalR)? I don't want to make use of any time-based solution like task scheduler as this will consume application pools and is ineffective. Any solutions?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Aswin Arshad
  • 90
  • 1
  • 11
  • 1
    You may take a look at this: https://stackoverflow.com/questions/7358322/notify-c-sharp-client-when-smtp-server-receive-a-new-email – csharpwinphonexaml Aug 24 '18 at 08:05
  • gmail api provides sub/pub https://developers.google.com/gmail/api/guides/push – Alex Terry Aug 24 '18 at 20:07
  • 1
    Anything you do within the context of your website will consume threads that your webserver would otherwise use. And it's not the job of a website to have a constantly running process to check your mail server. You should strongly consider setting up a completely separate application to accomplish this. – mason Nov 05 '18 at 21:13

0 Answers0