473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

emailing using SMTP, to an email address??

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
4 1830
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
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


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: MLH | last post by:
I print to a device that creates a PDF. Knowing the filename, how can I then embed the PDF into the body text of an OutLook Express outbound email & send to a specified address in a table? I want...
3
by: bill mahoney | last post by:
Hello, I am using access 2000 and I am trying to email a csv file. I have only used the docmd.sendobject command but you can only email objects that are within the access database ( as far as I...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
4
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI...
1
by: John Smith | last post by:
Server: Windows 2000 ..Net Framework: v1.1.4322.573 I have created a class in asp.net that sends out an email message. It used to work on the live server but now it doesn't? I never made any...
3
by: Sandy | last post by:
Hello - I am attempting to email error messages to myself in the event of an error. I am using the following code: Dim mail as New MailMessage() Dim ErrorMessage = "The error description is...
3
by: Elmo Watson | last post by:
I have a script I ran against a database table of emails - - sendning emails out to all who signed up - - However, I got the following error, running the script: The server rejected one or more...
5
by: =?Utf-8?B?Q2hhcmxlc0E=?= | last post by:
Hi folks, I'm using WinXP Pro svc pack 2, I'm the admin, I have VS2005 and .net framework 2.0 and I'm using ASP.net 2.0 I've never ever ever over the years had any luck (over the years) in...
20
by: paul814 | last post by:
I've been working on this for some time now and have gotten nowhere...hoping someone here can help. I want to take and email all records in a database for the current date when this php page is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.