SendGrid v6.3.4.0
VB 2017专业版
在Windows 10 64b Pro上
我想将SendGrid电子邮件添加到我的VB windows应用程序中 我没有问题地安装了NuGet SendGrid项目(添加引用等)。 但是我得到了构建错误(请参阅下面的Sub send_by_SendGrid中的位置):未声明“transportWeb”。
这一切都可以在我的另一台电脑上使用。
Imports SendGrid
...
Sub send_by_SendGrid(ByVal Addr, ByVal Subject, ByVal Message, ByVal From_Address)
' Prevent email problem with Verizon:
addr=replace(addr,"vzwpix","vtext",)
if subject = "" then
subject = " "
'Message = ""
End If
' Create the email object first, then add the properties.
Dim myMessage As SendGridMessage
myMessage = New SendGridMessage()
' Add the message properties.
myMessage.AddTo(Addr)
myMessage.From = New MailAddress(From_Address)
if Subject <> "" then
myMessage.Subject = Subject
end if
' Add plain text body only:
myMessage.Text = Message
Dim username As String
Dim pswd As String
username = "MYUSERNAME@azure.com"
pswd = "MY_PW"
Dim credentials As NetworkCredential
credentials = New NetworkCredential(username, pswd)
' // Create an Web transport for sending email.
transportWeb = New Web(credentials) <<<<<<<<<<<<<<< 'transportWeb' is not declared
transportWeb.DeliverAsync(myMessage) <<<<<<<<<<<<<<<<<< 'transportWeb' is not declared
End Sub
答案 0 :(得分:0)
变化:
transportWeb = New Web(credentials)
到
Dim transportWeb As New Web(credentials)