Auto Email Code
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hello all,
I need a Module that will allow my Usercontrol to send a Basic email to the user after registration.
I do have my on SMTP so thats not a problem. Its does NOT require SSL.
I just need it to send a generated password to the user email account. I have the password generator made and working. I just need a simple code that will email the code to the user.
Is there any one that has done something like this?
Scottie
I need a Module that will allow my Usercontrol to send a Basic email to the user after registration.
I do have my on SMTP so thats not a problem. Its does NOT require SSL.
I just need it to send a generated password to the user email account. I have the password generator made and working. I just need a simple code that will email the code to the user.
Is there any one that has done something like this?
Scottie
I found this simple code.
For Google Gmail Server.
Scottie
For Google Gmail Server.
Code: Select all
Now can anyone help me put it in a function instead of a click event?Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential(smtpUser, smtpPass)
'using gmail
smtpServer.Port = 587
smtpServer.Host = smtpServ
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress(fromUser)
mail.To.Add(toUser)
mail.Subject = (regSub)
mail.Body = TextBox1.Text
smtpServer.Send(mail)
MsgBox("Mail Sent Succesfull!")
Scottie
Hello Scottie,
You could just put it into a sub like this:
Hope that helps cooll;
You could just put it into a sub like this:
Code: Select all
Change the server settings in the code. And then use it by using this code whenever you want to send the email: Public Sub SendEmail(ByVal EmailAddress As String)
Dim from As New MailAddress("your@email.com")
Dim [to] As New MailAddress(EmailAddress)
Dim theMailMessage As New MailMessage(from, [to])
theMailMessage.Body = "This is the message I want to send to the user."
theMailMessage.Subject = "Email Subject"
Dim theClient As New SmtpClient("mail.server.com") 'EMAIL SERVER
theClient.UseDefaultCredentials = False
Dim theCredential As New System.Net.NetworkCredential("MyEmailUsername", "MyEmailPassword")
theClient.Credentials = theCredential
theClient.EnableSsl = True
theClient.Port = 587
Try
theClient.Send(theMailMessage)
Catch wex As Net.WebException
MessageBox.Show("Could not send email...check your settings.")
End Try
MsgBox("E-mail successfully sent")
End Sub
Code: Select all
And that will send an email to the address you specify.SendEmail("Someone@email.com")
Hope that helps cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023