Sending mail in ASP.NET
-
From the documentation of the SmtpClient class: If there is an e-mail transmission in progress and you call SendAsync or Send again, you will receive an InvalidOperationException. Does that mean users can't send mail (from different threads) at the same time? Also is there any way to get notified 'programmatically' when the mail is delivered? Thanks
Waleed Eissa Software Developer Sydney
-
From the documentation of the SmtpClient class: If there is an e-mail transmission in progress and you call SendAsync or Send again, you will receive an InvalidOperationException. Does that mean users can't send mail (from different threads) at the same time? Also is there any way to get notified 'programmatically' when the mail is delivered? Thanks
Waleed Eissa Software Developer Sydney
Waleed Eissa wrote:
Also is there any way to get notified 'programmatically' when the mail is delivered?
SendAsyc has an event that fires when it has sent. It's not very reliable, you can't know it was delivered, only that it was sent.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Waleed Eissa wrote:
Also is there any way to get notified 'programmatically' when the mail is delivered?
SendAsyc has an event that fires when it has sent. It's not very reliable, you can't know it was delivered, only that it was sent.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
Thanks a lot for your reply, actually I know about this event but I was hoping there's a more reliable way, basically what I'm trying to do is automate the whole process, this is why I don't want to use DeliveryOptions because I don't want to keep checking my email every now and then to make sure every message was sent, doesn't seem a very reliable way in a production environment. It seems that there's no way to communicate with the SMTP server, I wonder how all those websites with high traffic handle mail issues ..
Waleed Eissa Software Developer Sydney
-
Thanks a lot for your reply, actually I know about this event but I was hoping there's a more reliable way, basically what I'm trying to do is automate the whole process, this is why I don't want to use DeliveryOptions because I don't want to keep checking my email every now and then to make sure every message was sent, doesn't seem a very reliable way in a production environment. It seems that there's no way to communicate with the SMTP server, I wonder how all those websites with high traffic handle mail issues ..
Waleed Eissa Software Developer Sydney
No, there is literally no way to know if a mail got sent correctly, your best bet is to write a program that checks mail on the return address to see if you get a failure notice, but even that won't really work.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.