locked
how to send an autogenerated mail using vb.net RRS feed

  • Question

  • User429655465 posted

    Hi,

    i have a form with different fields like name, email id, comment etc and i want to receive a mail from the email id filled into email id field of the form, on submitting the form. And I have this code written as under but it doesn't give me any response but also not showing any kind  of error.

    public Function SendMail()
    dim client as New System.Net.Mail.SmtpClient("smtp.gmail.com",587)
    Dim msg As New System.Net.Mail.MailMessage()
    Dim subtext As String = "This is subject line"
    Dim bdtext As String = "Hi, This article is based on how to use System.Net.Mail namspace to send emails"

    msg.To.Add("myemailid@gmail.com")
    msg.From = New MailAddress("sendersid@gmail.com")
    msg.Subject = subtext
    msg.Body = bdtext
    msg.Priority = "high"

    client.Credentials = new Net.NetworkCredential("emailid@gmail.com", "password")
    client.EnableSsl = False
    client.UseDefaultCredentials = True

    client.Send(msg)

    also i am not aware of whether it is required to use credentials in my case or not, I think it is not required in my case.
    Please help me, I had already wasted lots of time onto it. I'll be very greatful to u.

    Rahul 

    Wednesday, April 3, 2013 10:15 AM

Answers

  • User3690988 posted

    Change this:

    client.EnableSsl = False
    client.UseDefaultCredentials = True

    To This:

    client.EnableSsl = True
    'client.UseDefaultCredentials = True   ' Comment out

    You must use a secured, authenticated connection.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 7, 2013 8:05 PM

All replies

  • User381600086 posted

    You have to use credential to do this. It will authenticate your mailing id and open the gate to send your mails. I hope you doing this for testing purpose if so then you can use.

    <mailSettings>     <smtp deliveryMethod='SpecifiedPickupDirectory'>         <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" />     </smtp> </mailSettings>

    http://code.msdn.microsoft.com/Fully-Loaded-Email-096bbe03

    Wednesday, April 3, 2013 10:24 AM
  • User429655465 posted

    does the lines of code used by me are correct?
    if it is then why is it not showing the response?

     

    Wednesday, April 3, 2013 10:32 AM
  • User3690988 posted

    Change this:

    client.EnableSsl = False
    client.UseDefaultCredentials = True

    To This:

    client.EnableSsl = True
    'client.UseDefaultCredentials = True   ' Comment out

    You must use a secured, authenticated connection.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 7, 2013 8:05 PM