Note that there are some explanatory texts on larger screens.

plurals
  1. PONotify C# Client, when SMTP Server receive a new Email
    text
    copied!<p>I want to get all emails in my ASP.NET application that have a certain CC-recipient. To use this for future emails I didn't want to polling all the time to get them. But I can't find a way, how I can use push to get the emails instantly. Are their any frameworks in C# to help me for this?</p> <p>I want to connect with my application to a mail server and register a method 'X'. Always when a new message arrived to the mail server, my application have to be notified and my application should execute the method 'X'.</p> <p>I hope that this is possible with code like this:</p> <pre><code>void Application_Start() { ... ConnectWithTheSmtpServer(); RegisterMethodForNotification(DoSomethink); ... } void DoSomethink(Mail newMail) { // Do Somethink with the mail } </code></pre> <p><strong>EDIT:</strong></p> <p>I did it with the <a href="http://mailsystem.codeplex.com/">MailSystem.Net</a>. It works very fine and is very easy to implement.</p> <p>Sample Code:</p> <pre><code>void Application_Start() { var worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(StartIdleProcess); if (worker.IsBusy) worker.CancelAsync(); worker.RunWorkerAsync(); } private void StartIdleProcess(object sender, DoWorkEventArgs e) { if (_imap != null &amp;&amp; _imap.IsConnected) { _imap.StopIdle(); _imap.Disconnect(); } _imap = new Imap4Client(); _imap.ConnectSsl(server-name, 993); _imap.Login(username, passwort); var inbox = _imap.SelectMailbox("INBOX"); _imap.NewMessageReceived += new NewMessageReceivedEventHandler(NewMessageReceived); inbox.Subscribe(); _imap.StartIdle(); } public static void NewMessageReceived(object source, NewMessageReceivedEventArgs e) { // Do something with the source... } </code></pre>
 

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