Tag: sendasync

在SendComplete中配置SmtpClient?

当我使用SmtpClient的SendAsync发送电子邮件时,如何正确配置smtpclient实例? 让我们说: MailMessage mail = new System.Net.Mail.MailMessage() { Body = MailBody.ToString(), IsBodyHtml = true, From = new MailAddress(FromEmail, FromEmailTitle), Subject = MailSubject }; mail.To.Add(new MailAddress(i.Email, “”)); SmtpClient sc = new SmtpClient(SmtpServerAddress); //Add SendAsyncCallback to SendCompleted sc.SendCompleted += new SendCompletedEventHandler(SendAsyncCallback); //using SmtpClient to make async send (Should I pass sc or mail into SendAsyncCallback?) sc.SendAsync(mail, sc); […]