我有一个使用sendgrid web api的工作函数。该功能没有任何问题,但现在我想添加一个" ReplyTo"电子邮件地址。工作代码如下:
Private Function CreateMailMessage(ByVal fromAddr As String, fromName As String, ByVal toAddr As String, ByVal ccAddr As String, ByVal bccAddr As String, ByVal subject As String, ByVal contents As String) As SendGrid.IMail
Dim returnVar As SendGrid.IMail = SendGrid.Mail.GetInstance
returnVar.From = New System.Net.Mail.MailAddress(fromAddr, fromName)
returnVar.Subject = subject
If contents.Contains("<html") Then
returnVar.Html = contents
Else
returnVar.Text = contents
End If
For Each aStr As String In toAddr.Split(CChar(";"))
returnVar.AddTo(aStr)
Next
If Not (String.IsNullOrWhiteSpace(ccAddr)) Then
For Each aStr As String In ccAddr.Split(CChar(";"))
'Sendgrid doesnt support CC via the webapi so we need to use Bcc
returnVar.AddBcc(aStr)
Next
End If
If Not (String.IsNullOrWhiteSpace(bccAddr)) Then
For Each aStr As String In bccAddr.Split(CChar(";"))
returnVar.AddBcc(aStr)
Next
End If
Return returnVar
End Function
当在ReplyTo中添加时我尝试了以下内容:
Private Function CreateMailMessage(ByVal replytoAddr As String, ByVal fromAddr As String, fromName As String, ByVal toAddr As String, ByVal ccAddr As String, ByVal bccAddr As String, ByVal subject As String, ByVal contents As String) As SendGrid.IMail
Dim returnVar As SendGrid.IMail = SendGrid.Mail.GetInstance
If Not (String.IsNullOrWhiteSpace(replytoAddr)) Then
returnVar.ReplyToList.Add(New System.Net.Mail.MailAddress(replytoAddr))
End If
returnVar.From = New System.Net.Mail.MailAddress(fromAddr, fromName)
returnVar.Subject = subject
If contents.Contains("<html") Then
returnVar.Html = contents
Else
returnVar.Text = contents
End If
For Each aStr As String In toAddr.Split(CChar(";"))
returnVar.AddTo(aStr)
Next
If Not (String.IsNullOrWhiteSpace(ccAddr)) Then
For Each aStr As String In ccAddr.Split(CChar(";"))
'Sendgrid doesnt support CC via the webapi so we need to use Bcc
returnVar.AddBcc(aStr)
Next
End If
If Not (String.IsNullOrWhiteSpace(bccAddr)) Then
For Each aStr As String In bccAddr.Split(CChar(";"))
returnVar.AddBcc(aStr)
Next
End If
Return returnVar
End Function
似乎回复者不是sendgrid的一部分?有谁见过这个?