c# - Unknown Failure to Send Email when using Async -
i have website needs send email on particular action.
var mail = new mailmessage("donotreply@mycompany.com", "myself@mycompany.com", "generic subject title", string.format("some body content"); using (var eserver = new smtpclient("mailsrv.mycompany.com")) { eserver.send(mail); }
the above code works fine, though send function takes between 8-15 seconds complete, receive email few seconds later. remove delay in page response @ least.
using (var eserver = new smtpclient("mailsrv.mycompany.com")) { eserver.sendmailasync(mail); }
when using above page loads , finishes other processes never receive email.
does have idea why wouldn't receive email because i'm using async version?
because of using block, dispose 'eserver' variable before has chance send mail. if use sendmailasync, should not directly dispose smtpclient afterwards.
Comments
Post a Comment