我正在使用Mail.MailMessage和Mail.SmtpClient在.net应用程序中向客户端发送电子邮件。 使用的主机是mandrill的SMTP,但是我没有使用其电子邮件发送API(仅是SMTP服务器)
是否有一种方法可以从Mandrill获取有关已发送电子邮件的代码的响应(电子邮件状态),但是使用SMTPClient而不是其API? 我知道这在Mandrill仪表板中可用,您可以在其中查看是否拒绝/接受电子邮件,但是在Send(mail)发生后,我需要在代码中使用它。
Public Sub Send()
Try
Dim mail As New System.Net.Mail.MailMessage
With mail
.To.Add(New System.Net.Mail.MailAddress("test@test.com"))
.CC.Add(New System.Net.Mail.MailAddress("test1@test.com"))
.From = New System.Net.Mail.MailAddress("test2@test.com")
.ReplyTo = New Net.Mail.MailAddress("test@test.com")
.Subject = Me.Subject
.Body = Me.Body
.Attachments.Add(att)
Dim msg As New System.Net.Mail.SmtpClient
Dim crd As String = System.Configuration.ConfigurationManager.AppSettings("SMTPNetworkCredential")
If crd Is Nothing Then
msg.UseDefaultCredentials = True
Else
Dim c() As String = crd.Split(",")
msg.UseDefaultCredentials = False
msg.Credentials = New System.Net.NetworkCredential(c(0), c(1))
End If
msg.Host = "smtp.mandrillapp.com"
msg.Port = 587
msg.Send(mail)
End With
Catch ex As Exception
Throw ex
End Try
结束子