help with purchase order form

mjcs100

Newcomer
Joined
Feb 19, 2006
Messages
7
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
 
Last edited:
The section of code
Visual Basic:
If DeliveryNotificationOptions.OnSuccess = DeliveryNotificationOptions.OnSuccess Then
MessageBox.Show("Information Was Successfully Submitted")
ElseIf DeliveryNotificationOptions.OnFailure = DeliveryNotificationOptions.OnFailure Then
MessageBox.Show("Information Was Not Submitted")
will always return true as you are simply comparing DeliveryNotificationOptions.OnSuccess to itself - in fact this enumeration is not intended to be a way of checking but of specifying what notifications you would like, you need to set the DeliveryNotificationOptions property of the message itself before sending.

Does the local PC have IIS / SMTP installed and configured to allow sending of e-mails? Also when you tried sending via a smtp server did it return any errors? If not did the account you were using have permissions to send / relay through that server?
 
Thanks PlausiblyDamp for replying. I checked the local pc under administrative tools/services and it says the Iis is running. I don't see anything about smtp though. I dont know anything hardly at all when it comes to things about admisistrative tools, but wouldnt the smtp be installed if i can send mail through the default email handler? That's what I originally was trying to do was to get the submit button to use the default mail handler of the person's pc that wanted to purchase the product. I just used the deliverynotificationoption to see if it went through ok, which I just removed.

Yes I got an error when I tried to send it via smtp. I uploaded a jpeg of it to show you. Is there something I'm missing in the code above that directs the info to be sent from someones computer using their default mail client?
Thanks
 

Attachments

Back
Top