如何发送异步电子邮件?

时间:2021-04-07 18:14:03

I am trying to send inventory updates to users who have made a request to be emailed when it becomes available. The system is a P2P system. A user will add their inventory and when that happens I want to trigger the email sending.

我正在尝试向已发出请求的用户发送库存更新,以便在可用时通过电子邮件发送。该系统是P2P系统。用户将添加他们的库存,当发生这种情况时,我想触发电子邮件发送。

I want this process to be done without the user having to wait for these emails to be sent. I want this to be fire and forget. The client that adds the inventory needs not know that the emails were sent nor does the page that he is on know that the emails were sent successfully

我希望在没有用户等待发送这些电子邮件的情况下完成此过程。我希望这是火和忘记。添加库存的客户端不需要知道电子邮件已发送,他所在的页面也知道电子邮件已成功发送

Everywhere I have seen for a solution to this requires that I set up a web-service to handle this. Is this true? If so, could someone send me in the right direction on where to learn the how to write a web service and it's interface like this.

我已经看到解决这个问题的任何地方都需要我设置一个Web服务来处理这个问题。这是真的?如果是这样,有人可以向我发送正确的方向,了解如何编写Web服务以及它的界面。

3 个解决方案

#1


2  

This isn't exactly an answer to your question but sending an email is a very quick process, even if the SMTP server isn't local. I have done this same thing before without doing an async process and the delay isn't noticable.

这不是您的问题的答案,但发送电子邮件是一个非常快速的过程,即使SMTP服务器不是本地的。在没有进行异步处理之前我做过同样的事情并且延迟并不明显。

#2


0  

You could just use a thread to send the email on.

您可以使用线程发送电子邮件。

using System.Threading;

Thread t = new Thread(()=>{ 
//put code here that would send your email
 });
t.IsBackground = true;
t.Start(); //this actually will startup the thread and run your code.

#3


0  

What version of .NET?

什么版本的.NET?

Couldn't you just kick-off a process in a new thread that builds and sends an email?

难道你不能在一个构建和发送电子邮件的新线程中启动一个进程吗?

The user wouldn't have to wait then...

用户不必等待......

#1


2  

This isn't exactly an answer to your question but sending an email is a very quick process, even if the SMTP server isn't local. I have done this same thing before without doing an async process and the delay isn't noticable.

这不是您的问题的答案,但发送电子邮件是一个非常快速的过程,即使SMTP服务器不是本地的。在没有进行异步处理之前我做过同样的事情并且延迟并不明显。

#2


0  

You could just use a thread to send the email on.

您可以使用线程发送电子邮件。

using System.Threading;

Thread t = new Thread(()=>{ 
//put code here that would send your email
 });
t.IsBackground = true;
t.Start(); //this actually will startup the thread and run your code.

#3


0  

What version of .NET?

什么版本的.NET?

Couldn't you just kick-off a process in a new thread that builds and sends an email?

难道你不能在一个构建和发送电子邮件的新线程中启动一个进程吗?

The user wouldn't have to wait then...

用户不必等待......