I have a .NET Web Application that wants to use SendGrid smtp server to send emails.
Its a simple one page app, which has its code in Page_Load. I have imported the references to the SendGrid via Nu-Get and the reference is fine too.
code goes to timeout error after a while when it reaches – transportSMTP.Deliver(myMessage).
can somebody please help?
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
Found a solution:
– Package the cloud (.Azure) project using visual studio (2012 or 2010) on framework 4.0
– login to Windows Azure Portal and upload the package.
for help please refer this – https://www.windowsazure.com/en-us/manage/services/cloud-services/how-to-create-and-deploy-a-cloud-service/
(silly me, i was just worrying about proxies and stuff when i had the solution right in front of me 😛 )