Hi. I was wandering if you could look at my code i have for a submit button on a purchase order form. In the program when a customer wants to purchase the product, I want the info from the form to be emailed to me from the form. I checked out different sites with different answers but nothing works. I had to pick the delivery method as "PickupDirectoryFromIis" b/c it wouldnt let me specify a default mail client. I stepped through the code and it said it was successfully sent but it never comes in my default emailclient. Here is the code for a submit button.
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim email As New MailMessage
Dim messageBody As String = "LblProdName.Text" & "lblProdCode.Text" & "txtFName.Text" & "txtLName.Text" & "txtAdd1.Text" & "txtAdd2.Text" & "txtCity.Text" & "txtZipCode.Text" & "txtPhone.Text" & "txtEmailAddress.Text"
Dim smtp As New SmtpClient
Try
email.From = New MailAddress("user@localhost")
email.To.Add("me@mydomain.net")
email.Subject = "Submitted Information"
email.Body = messageBody.ToString
smtp.Host = ("mail.domain.net")
smtp.Port = 25
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
smtp.Send(email)
If DeliveryNotificationOptions.OnSuccess = DeliveryNotificationOptions.OnSuccess Then
MessageBox.Show("Information Was Successfully Submitted")
ElseIf DeliveryNotificationOptions.OnFailure = DeliveryNotificationOptions.OnFailure Then
MessageBox.Show("Information Was Not Submitted")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString())
email = Nothing
End Try
txtFName.Text = ""
txtLName.Text = ""
txtAdd1.Text = ""
txtAdd2.Text = ""
txtCity.Text = ""
txtZipCode.Text = ""
txtPhone.Text = ""
txtEmailAddress.Text = ""
cboState.Text = "Please Select"
cboCountry.Text = "Please Select"
cboVisa.Checked = False
cboMasterCard.Checked = False
cboDiscover.Checked = False
cboAmExp.Checked = False
rdoShareIt.Checked = False
rdoPayPal.Checked = False
Me.Close()
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim email As New MailMessage
Dim messageBody As String = "LblProdName.Text" & "lblProdCode.Text" & "txtFName.Text" & "txtLName.Text" & "txtAdd1.Text" & "txtAdd2.Text" & "txtCity.Text" & "txtZipCode.Text" & "txtPhone.Text" & "txtEmailAddress.Text"
Dim smtp As New SmtpClient
Try
email.From = New MailAddress("user@localhost")
email.To.Add("me@mydomain.net")
email.Subject = "Submitted Information"
email.Body = messageBody.ToString
smtp.Host = ("mail.domain.net")
smtp.Port = 25
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
smtp.Send(email)
If DeliveryNotificationOptions.OnSuccess = DeliveryNotificationOptions.OnSuccess Then
MessageBox.Show("Information Was Successfully Submitted")
ElseIf DeliveryNotificationOptions.OnFailure = DeliveryNotificationOptions.OnFailure Then
MessageBox.Show("Information Was Not Submitted")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString())
email = Nothing
End Try
txtFName.Text = ""
txtLName.Text = ""
txtAdd1.Text = ""
txtAdd2.Text = ""
txtCity.Text = ""
txtZipCode.Text = ""
txtPhone.Text = ""
txtEmailAddress.Text = ""
cboState.Text = "Please Select"
cboCountry.Text = "Please Select"
cboVisa.Checked = False
cboMasterCard.Checked = False
cboDiscover.Checked = False
cboAmExp.Checked = False
rdoShareIt.Checked = False
rdoPayPal.Checked = False
Me.Close()
End Sub
Last edited by a moderator: