emailing using SMTP, to an email address??

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

I have this code on one of my forms, the code takes whatever is in
textboxes and adds it to a MS Access Database. It then shows a
message that the operation was completed.

Is there a universal command or code to send an email to the email
entered in txtemail.text
How would I do something like that?

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click


Dim conn As New OleDbConnection("Provider=Microsoft.jet.oledb.
4.0;" & _
"Data Source=helpdesk.mdb")
Using (conn)
conn.Open()
Dim com As OleDbCommand = conn.CreateCommand()
Using (com)
com.CommandType = CommandType.Text
com.CommandText = String.Format("Insert Into
help(Name, Email, telephone, description) Values ('{0}', '{1}', '{2}',
'{3}')", txtName.Text, txtEmail.Text, txtTelephone.Text,
txtDescription.Text)
com.ExecuteNonQuery()
End Using
End Using
MessageBox.Show("Record added to database and email sent.")
Me.Close()
frmMain.Show()
End Sub
End Class
 
I have this code on one of my forms, the code takes whatever is in
textboxes and adds it to a MS Access Database. It then shows a
message that the operation was completed.

Is there a universal command or code to send an email to the email
entered in txtemail.text
How would I do something like that?

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click

Dim conn As New OleDbConnection("Provider=Microsoft.jet.oledb.
4.0;" & _
"Data Source=helpdesk.mdb")
Using (conn)
conn.Open()
Dim com As OleDbCommand = conn.CreateCommand()
Using (com)
com.CommandType = CommandType.Text
com.CommandText = String.Format("Insert Into
help(Name, Email, telephone, description) Values ('{0}', '{1}', '{2}',
'{3}')", txtName.Text, txtEmail.Text, txtTelephone.Text,
txtDescription.Text)
com.ExecuteNonQuery()
End Using
End Using
MessageBox.Show("Record added to database and email sent.")
Me.Close()
frmMain.Show()
End Sub
End Class

Sure, look at System.Net.Mail.SmtpClient. If you need further help
after looking it over, let us know.
 
Sure, look at System.Net.Mail.SmtpClient. If you need further help
after looking it over, let us know.

thanks here is what I have, is there a way I can be prompted for my
username and password so that I do not have to put it in the code?
Also is there a way I could be prompted for the SMTP server so that I
do not need to hard code it?

How would I do this?
.....
'send email

'create the mail message
Dim mail As New Net.Mail.MailMessage()

'set the addresses
mail.From = New Net.Mail.MailAddress("(e-mail address removed)")
mail.To.Add("(e-mail address removed)")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."

'send the message
Dim smtp As New
Net.Mail.SmtpClient("smtp.woodworkandmore.com")

'to authenticate we set the username and password properites
on the SmtpClient
smtp.Credentials = New Net.NetworkCredential("myusername",
"mypassword")
smtp.Send(mail)
 
I have this code on one of my forms, the code takes whatever is in
textboxes and adds it to a MS Access Database. It then shows a
message that the operation was completed.

Is there a universal command or code to send an email to the email
entered in txtemail.text
How would I do something like that?

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click

Dim conn As New OleDbConnection("Provider=Microsoft.jet.oledb.
4.0;" & _
"Data Source=helpdesk.mdb")
Using (conn)
conn.Open()
Dim com As OleDbCommand = conn.CreateCommand()
Using (com)
com.CommandType = CommandType.Text
com.CommandText = String.Format("Insert Into
help(Name, Email, telephone, description) Values ('{0}', '{1}', '{2}',
'{3}')", txtName.Text, txtEmail.Text, txtTelephone.Text,
txtDescription.Text)
com.ExecuteNonQuery()
End Using
End Using
MessageBox.Show("Record added to database and email sent.")
Me.Close()
frmMain.Show()
End Sub
End Class

www.systemnetmail.com

Thanks,

Seth Rowe
 
Back
Top