0

我有一个想要使用 SendGrid smtp 服务器发送电子邮件的 .NET Web 应用程序。

它是一个简单的单页应用程序,其代码位于Page_Load. 我已经通过 Nu-Get 导入了对 SendGrid 的引用,并且引用也很好。代码在一段时间后到达 - 时出现超时错误transportSMTP.Deliver(myMessage)。有人可以帮忙吗?

Imports System.Net
Imports System.Net.Mail
Imports SendGridMail
Imports SendGridMail.Transport

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Creating Email object for SendGrid
        Dim myMessage As SendGrid = SendGrid.GenerateInstance()
        myMessage.AddTo("RAMESHV@timken.com")
        myMessage.From = New MailAddress("myemail@domain.com", "Vikram Avadhaani")
        myMessage.Subject = "Testing the SendGrid Library"
        myMessage.Text = "<p>Show's over Amigo!</p> <br/> It ain't over, 'till its over!"

        'Create Credentials with UserName and Password
        Dim mailCredentials = New NetworkCredential("<user id>", "<password>")

        'Creating an SMTP Transport for sending email
        Dim transportSMTP As SMTP = SMTP.GenerateInstance(mailCredentials)  'SMTP
        Dim transportREST As REST = REST.GetInstance(mailCredentials)       'REST

        'Send the email
        transportSMTP.Deliver(myMessage)
        'transportREST.Deliver(myMessage)
    End Sub

End Class
4

1 回答 1

0

找到解决方案: - 在框架 4.0 上使用 Visual Studio(2012 或 2010)打包云(.Azure)项目 - 登录到 Windows Azure 门户并上传包。如需帮助,请参阅 - https://www.windowsazure.com/en-us/manage/services/cloud-services/how-to-create-and-deploy-a-cloud-service/

(愚蠢的我,当我面前有解决方案时,我只是担心代理和其他东西:P)

于 2012-10-02T06:23:04.070 回答