Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Trying to Send an Email when a Page Loads

$
0
0

Hello All,

I am trying to send an email everytime a page loads.

This is my code

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
Dim message = New MailMessage()
message.From = New MailAddress("noreply@doman.com")
message.To.Add(New MailAddress("user@domain.com"))
message.Subject = "This is my subject"
message.Body = "This is the content"
Dim client As New SmtpClient()
client.Send(message)
End Sub

This works for sending the email, but if the Page stays open, it keeps sending the Email until i close the page...

How can i get it to send only ONCE when the page is loaded

Thanks in advance


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>