none
sending email using VB.NET ? RRS feed

  • Question

  • Can any one help in sending email from my website VWB....

     Dim mailServerName As String = "smtp.gmail.com"
            Dim message As MailMessage = New MailMessage(fromaddress, toaddress,subject, body)
            Dim mailClient As SmtpClient = New SmtpClient

            mailClient.Host = mailServerName
           
            mailClient.Send(message)
            message.Dispose()

    i get this error...



    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required y37sm4414792iky


    Saturday, April 21, 2007 5:40 PM

Answers

  • Hi! Arjun

     

    Dude where is the password ? You have used smtp.gmail.com and your email id as from address. Thats right. But where is the password to authenticate you gmail account ?

     

    Assuming you are using VB.NET and ASP.NET the solution is:

     

    go to web.config file and the following lines

    <system.net>
      <mailSettings>
       <smtp>
        <network host="smtp.gmail.com" port="25" userName="yourid@gmail.com" password="your password"/>
       </smtp>
      </mailSettings>
     </system.net>

     

    ----------------------------------------------------------------------------------

    Please mark as answer if my post answers your question

    Sunday, April 22, 2007 2:00 PM

All replies

  • Hi! Arjun

     

    Dude where is the password ? You have used smtp.gmail.com and your email id as from address. Thats right. But where is the password to authenticate you gmail account ?

     

    Assuming you are using VB.NET and ASP.NET the solution is:

     

    go to web.config file and the following lines

    <system.net>
      <mailSettings>
       <smtp>
        <network host="smtp.gmail.com" port="25" userName="yourid@gmail.com" password="your password"/>
       </smtp>
      </mailSettings>
     </system.net>

     

    ----------------------------------------------------------------------------------

    Please mark as answer if my post answers your question

    Sunday, April 22, 2007 2:00 PM
  • You have to use Credential property to authenticate.
    Tuesday, April 24, 2007 2:37 PM
  • hai arul,

    Thanks for your time , should i use this code in web.config along with my sample.aspx.vb code which i have already posted???
    Tuesday, April 24, 2007 4:33 PM
  • Yes Arjun
    Tuesday, April 24, 2007 5:46 PM
  • While using VB.NET and ASP.NET the solution to ur problem is given below. You have not mentioned the password.

     
      Go to web.config file and the following lines

    <system.net>
      <mailSettings>
       <smtp>
        <network host="smtp.gmail.com" port="25" userName="yourid@gmail.com" password="your password"/>
       </smtp>
      </mailSettings>
     </system.net> .....
    This is all....

    Wednesday, April 25, 2007 11:24 AM
  • what is credential property ? can u help me out ? i have to send simple mail from  VWD  website ....
    Wednesday, April 25, 2007 5:48 PM
  • hi,


    web.config


        <system.net>
            <mailSettings>
                <smtp>
                    <network host="smtp.gmail.com" port="25" userName="arjdj08@gmail.com" password="codemaster@2kool"/>
                </smtp>
            </mailSettings>
        </system.net>



    sample.aspx.vb

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim mailServerName As String = "smtp.gmail.com,username="to@gmail.com",password="password""
            Dim message As MailMessage = New MailMessage("from@gmail.com", "to@gmail.com", "hai", "welcome")
            Dim mailClient As SmtpClient = New SmtpClient
            mailClient.Host = mailServerName
            mailClient.Send(message)
            message.Dispose()
        End Sub



    is this correct?
    Wednesday, April 25, 2007 6:04 PM