ryanbecker24
asked on
How do I send an email in ASP.NET?
Is this right?
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Mail
Partial Class Submit
Inherits System.Web.UI.Page
Dim objdt As System.Data.DataTable
Dim objdr As System.Data.DataRow
Dim ds As New DataSet
Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim strConnection As String = "Data Source=mssql102.manage.myhosting.com;Initial Catalog=db1150602_group3;Integrated Security=False;User ID=u1150602_drnicholsongroup3;Password=w6p?K9x!,l;Connect Timeout=15;Encrypt=False;Packet Size=4096"
Dim objconnection As New SqlConnection(strConnection)
Dim mysqlDataAdapter As New SqlDataAdapter("select * From Faculty", objconnection)
Dim myDataRow As DataRow
Dim mydatarowscommandbuilder As New SqlCommandBuilder(mysqlDataAdapter)
mysqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
mysqlDataAdapter.Fill(ds, "Faculty")
myDataRow = ds.Tables("Faculty").NewRow()
myDataRow("Work Title") = txtWorkTitle.Text
myDataRow("Co-Authors") = txtCoAuthor.Text
myDataRow("Additional Info") = txtAddInfo.Text
ds.Tables("Faculty").Rows.Add(myDataRow)
mysqlDataAdapter.Update(ds, "Faculty")
txtWorkTitle.Text = ""
txtCoAuthor.Text = ""
txtCoAuthor2.Text = ""
txtCoAuthor3.Text = ""
txtCoAuthor4.Text = ""
txtCoAuthor5.Text = ""
txtAddInfo.Text = ""
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("username@rowan.edu", "password")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress("username@rowan.edu")
e_mail.To.Add("username@rowan.edu")
e_mail.Subject = "Email Sending"
e_mail.IsBodyHtml = False
e_mail.Body = DropDownList1.DataTextField
e_mail.Body = txtWorkTitle.Text
e_mail.Body = txtCoAuthor.Text
e_mail.Body = txtCoAuthor2.Text
e_mail.Body = txtCoAuthor3.Text
e_mail.Body = txtCoAuthor4.Text
e_mail.Body = txtCoAuthor5.Text
e_mail.Body = txtAddInfo.Text
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
End Sub
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles btnAdd.Click
If (txtCoAuthor2.Visible = False) Then
txtCoAuthor2.Visible = True
End If
If (txtCoAuthor3.Visible = False) Then
txtCoAuthor2.Visible = True
txtCoAuthor3.Visible = True
End If
If (txtCoAuthor4.Visible = False) Then
txtCoAuthor2.Visible = True
txtCoAuthor3.Visible = True
txtCoAuthor4.Visible = True
End If
If (txtCoAuthor5.Visible = False) Then
txtCoAuthor2.Visible = True
txtCoAuthor3.Visible = True
txtCoAuthor4.Visible = True
txtCoAuthor5.Visible = True
End If
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.