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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Sending email via ASP.NET (VB)

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