How to send mail from multiple threads simultaneously and get notified of delivery?
-
I'm creating a website where users can send mail messages to each other through the website (they don't see the email address of the receiver) 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. That doesn't sound very good :( I assume that I have to create a queue class for sending messages because users can be sending messages at the same time (which means many threads calling SmtpClient.Send() at the same time), is this correct? I have another issue too, I noticed that when I send mail from my local machine, some messages are delivered but the majority are not, and even those messages that were successfully delivered, many of them took way too long to be delivered, up to many days with some of them!! I know that there must be something wrong, but I have no idea what, I have checked everything on my computer but everything seemed ok (I checked the SMTP settings, esp. the relay settings, and they were OK. I also checked the settings of the anti-virus software and found it wasn't blocking the outbound SMTP messages), I'm worried it might cause problems later on the production server. Is there any way to get notified of the delivery of messages, I save the messages to a database when the user clicks the Send button, now I want a reliable way of knowing whether the message was delivered or not (I have a field in the database that I use as a flag, I want to set it to true when the message is sent so that I can know what was sent and what wasn't in order to try to send it again), can this be done with the mail classes in the .net framework or do I need some component that's more reliable? If so, do you have any suggestions for a good component? (preferably something you have personal experience with). Sorry for my long post, but I want to mention one last thing. As far as I understand, and please correct me if I'm wrong, SmtpClient.Send() only delivers the messages to the SMTP server and that's it, so if the messages are delivered to the SMTP server and not sent after that there's no way to find out, is this correct? Thank you for taking the time to read my post, any suggestions are very much appreciated ..
Waleed Eissa Software Developer Sydney
-
I'm creating a website where users can send mail messages to each other through the website (they don't see the email address of the receiver) 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. That doesn't sound very good :( I assume that I have to create a queue class for sending messages because users can be sending messages at the same time (which means many threads calling SmtpClient.Send() at the same time), is this correct? I have another issue too, I noticed that when I send mail from my local machine, some messages are delivered but the majority are not, and even those messages that were successfully delivered, many of them took way too long to be delivered, up to many days with some of them!! I know that there must be something wrong, but I have no idea what, I have checked everything on my computer but everything seemed ok (I checked the SMTP settings, esp. the relay settings, and they were OK. I also checked the settings of the anti-virus software and found it wasn't blocking the outbound SMTP messages), I'm worried it might cause problems later on the production server. Is there any way to get notified of the delivery of messages, I save the messages to a database when the user clicks the Send button, now I want a reliable way of knowing whether the message was delivered or not (I have a field in the database that I use as a flag, I want to set it to true when the message is sent so that I can know what was sent and what wasn't in order to try to send it again), can this be done with the mail classes in the .net framework or do I need some component that's more reliable? If so, do you have any suggestions for a good component? (preferably something you have personal experience with). Sorry for my long post, but I want to mention one last thing. As far as I understand, and please correct me if I'm wrong, SmtpClient.Send() only delivers the messages to the SMTP server and that's it, so if the messages are delivered to the SMTP server and not sent after that there's no way to find out, is this correct? Thank you for taking the time to read my post, any suggestions are very much appreciated ..
Waleed Eissa Software Developer Sydney
Oh, by the way, I'm aware of DeliveryNotificationOptions but it's not what I'm looking for, I want to get a notification (not an email) that I can use to update the flag in my database. Well, it seems that it's not possible but would anybody confirm that? Thanks.
Waleed Eissa Software Developer Sydney