I'm using a code on a site that sends an automated mail message to the business owner after a customer filled out a contact form. (I created it in Visual Studio 2003)
For some reason, the mail never gets sent out. Originally, I thought that I could just use "localhost" as the SMTP server, but I was told it would never work.
I called the Hosting Company to find out the SMTP address and I changed the code.
Here's what the code looks like: (I changed the email address and server address to cover my 4$$)
As you can see I created a private sub, and called it in the next function.
Private Sub Mail()
Dim msg As New Mail.MailMessage
Dim EmailTo As String
Dim MsgBody As String
Dim msgtext As String
Dim SmtpMail As Mail.SmtpMail
EmailTo = "Name@blankemail.com"
msg.To = EmailTo
msgtext = "Customer Name: " & Me.txtName.Text & Chr(13) & "Customer Phone Number: " & Me.txtPhnNum.Text & Chr(13) & "Customer Email: " & Me.txtEmail.Text & Chr(13) & "Best Time To Call: " & Me.txtTimeCall.Text & Chr(13) & "Additional Comments: " & Me.txtComments.Text
MsgBody = "A potential customer has filled out the request for contact page. See information listed below:"
msg.From = "CompanyPicnicCompany.com"
msg.Subject = "Customer Contact Request"
msg.Body = MsgBody & Chr(13) & msgtext
SmtpMail.SmtpServer = "http://smtp.blankemail.com"
SmtpMail.Send(msg)
End Sub
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Call Mail()
SendMessage("Thank you for filling out the Information Request Form. Someone will contact you within 24 hours.")
Response.Redirect("HOME.htm")
End Sub