【问题标题】:VB.NET SendGrid error "transportWeb" is not declaredVB.NET SendGrid 错误“transportWeb”未声明
【发布时间】:2017-09-08 00:48:30
【问题描述】:

SendGrid v6.3.4.0
VB 2017 专业版
在 Windows 10 64b 专业版上

我想将 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

【问题讨论】:

  • 看来需要声明transportWeb

标签: c# .net vb.net sendgrid


【解决方案1】:

变化:

transportWeb = New Web(credentials)

Dim transportWeb As New Web(credentials)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-20
    • 2023-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多