views:

41

answers:

2

Is it possible to automatically link the sending of an email (using SMTPClient) in C# with an ADO.net transaction?

So given the scenario of the sending of an email failing, the ADO.NET transaction will also fail and be automatically rolled back?

Cheers

+1  A: 

Yes, you need to send your mail within a transaction context and wait for completion, then just roll back transaction on any exception or commit it if there is no any. There is no common way to do this.

Restuta
A: 

You can rollback the transaction (or transaction scope) if an error sending the mail occurs. (As long as you don't want to undo the mail send as part of the transaction rollback... ;) )

However, I'm not sure what you mean by "automatic" linking; a failed e-mail send does not automatically perform a rollback.

Lucero