I am putting this question out there because it took me the better part of two days figuring this out by putting answers together.
I was attempting to receive AWS’s MessageID that it assigns to an email so that I could later use SNS/SQS to receive email feedback. And using System.Net.SmtpClient responded with a void for successful emails. You only received exception codes on a failure.
AWS will always send a response, but to get the message on success I needed to incorporate MailKit nuget and use the MessageSent event.
The resposne looks like this…. "OK xxxxx-xxxxxx-xxxxxx-xxxxx" where x’s are the newly assigned messageID.
2
Answers
Below is the simplest code to send an email with the method I used to get the messageID from the successful response. I hope this saves people a lot of time!
Simply use MailKit nuget and the following code:
I believe that starting with MailKit 3.0, the Send() and SendAsync() methods now return a string value so that you don’t actually need to listen to the MessageSent event: