Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Sending email via ASP.NET (VB)

  • 04-04-2007 02: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