locked
Sending Email with System.Net.Mail.SmtpClient RRS feed

  • Question

  • Hi to all,

    I am tying to send email from the website running on windows azure and using the 

    Imports System.Net
    Imports System.Net.Mail

    and my code is

     Protected Sub SendTTestMail(ByVal sender As Object, ByVal e As EventArgs)
            Dim myMail As New MailMessage
            myMail.Subject = "Test Mail "
            myMail.From = New MailAddress("alokdixit.pss@gmail.com")
            myMail.[To].Add(New MailAddress("alokdixit.pss@gmail.com"))
            myMail.IsBodyHtml = True

            myMail.Body = "Testing mail only please don't take another way."
            Dim mSmtpClient As New SmtpClient()
    //http://stanthony.cloudapp.net:85(at this url my project is running.)
            mSmtpClient.Host = "http://stanthony.cloudapp.net"
            mSmtpClient.Port = 85
             mSmtpClient.Send(myMail)
            MsgBox("sent mail.")
            myMail = Nothing
        End Sub

    but showing time expire error ...please help me am my mSmtpClient.Host = "http://stanthony.cloudapp.net"
            mSmtpClient.Port = 85 are right .i have also checked it by setting the IP at the place of the  host but receiving error.

    please any one help me

    Thanks 

    Alok dixit.


    Alok Dixit

    Monday, December 10, 2012 11:44 AM

All replies

  • Hi,

    Please include belwo two lines in your code.

    mSmtpClient.EnableSsl = true;

    mSmtpClient.Port = 587;

    For more details check the below link provided and use the same code.

    http://www.aspdotnetfaq.com/Faq/How-to-send-HTML-Email-from-ASP-NET-using-your-Gmail-account.aspx


    PS.Shakeer Hussain

    Monday, December 10, 2012 12:06 PM
  • Thanks alot for your quick reply....

    But my project is running on the port 85....?

    I let u know after checking. 

    Thanks 

    Alok dixit.


    Alok Dixit


    • Edited by AlokDixit Monday, December 10, 2012 12:23 PM
    Monday, December 10, 2012 12:22 PM
  • i am receiving error 

    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 111.221.82.9:587

    i would like to know you that i am not using gmail smtp.

    I am unable to track out the probem

    Thanks 

    Alok..


    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 111.221.82.9:587


    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 111.221.82.9:587


    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 111.221.82.9:587


    Alok Dixit

    Monday, December 10, 2012 12:31 PM
  • Ok,

    Then try with

    mSmtpClient.Port = 85 //and

    mSmtpClient.EnableSsl = true;


    PS.Shakeer Hussain

    Monday, December 10, 2012 12:33 PM
  • Hi .....there is error

    The operation has timed out.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.Net.Mail.SmtpException: The operation has timed out.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    i have set in web.config

    <system.net>
        <mailSettings>
          <smtp>
            <network host="stanthony.cloudapp.net" port="85" />
          </smtp>
        </mailSettings>
      </system.net>

    Is there any more changes required ....

    Thanks and Regards

    Alok


    Alok Dixit


    • Edited by AlokDixit Monday, December 10, 2012 12:41 PM
    Monday, December 10, 2012 12:41 PM
  • Hi,

    Check this link

    http://forums.asp.net/t/1820367.aspx/1


    PS.Shakeer Hussain

    Monday, December 10, 2012 12:51 PM
  • hi .

    I checked web.net and also above given mail ...

    both are not working , shall i have to setup any setting on azure ..please tell me if any?

    Thanks and regards

    alok dixit.


    Alok Dixit

    Friday, December 14, 2012 7:21 AM
  • Hi to all..

    Now i have decided to use send grid for sending mail.

    please tell me how can i check sending mail from local server before publishing the projects on azure.

    Thanks

    Alok dixit


    Alok Dixit

    Friday, December 28, 2012 6:39 AM