By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,494 Members | 976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,494 IT Pros & Developers. It's quick & easy.

emailing using SMTP, to an email address??

P: n/a
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

May 8 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 8, 1:24 pm, Ron <pts4...@yahoo.comwrote:
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.

--
Tom Shelton

May 8 '07 #2

P: n/a
Ron
On May 8, 4:08 pm, Tom Shelton <tom_shel...@comcast.netwrote:
On May 8, 1:24 pm, Ron <pts4...@yahoo.comwrote:
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.

--
Tom Shelton
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("su*****@helpdesk.com")
mail.To.Add("pu****@psu.edu")

'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)

May 8 '07 #3

P: n/a


Check this blog:
2/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)
http://sholliday.spaces.live.com/blog/
The code is in c#, but you'll be able to see the syntax.


"Ron" <pt*****@yahoo.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
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

May 8 '07 #4

P: n/a
On May 8, 3:24 pm, Ron <pts4...@yahoo.comwrote:
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

May 8 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.