Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sending email via ASP.NET (VB)

  • 04-04-2007 2:47pm
    #1
    Registered Users, Registered Users 2 Posts: 500 ✭✭✭


    Need to auto send an email upon click of a button. am searching the web for it - but cannot find a plain simple example - any help?


Comments

  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Have a function in your code behind that handles your button click

    Use the SMTPClient class to send the mail

    http://msdn2.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx


  • Registered Users, Registered Users 2 Posts: 500 ✭✭✭warrenaldo


    its ok having seaarched for longer and longer i found the simplest solution i could find. Ill post it as it may help others looking to simple send an email.

    Dim myMessage As New Net.Mail.MailMessage()
    Dim myMailServer As New Net.Mail.SmtpClient()
    Dim sFrom As New Net.Mail.MailAddress("from address")
    Dim sTo As New Net.Mail.MailAddress("recieve address")
    Dim sSubject As String = "TestSubject!"
    Dim sBody As String = "Message"

    With myMessage
    .From = sFrom
    .To.Add(sTo)
    .Subject = sSubject
    .Body = sBody
    End With
    myMailServer.Host = "myhost"
    myMailServer.Send(myMessage)


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    God the vb With!

    A really handy thing if there ever was one, I do miss it.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    SMTPClient is the only thing you need for .NET Mail Sending .. :)


Advertisement