I tried a script using System.Net.Mail, and configuring some lines in the web.config.
Well what happened is that it only sends mail on the address you configured in the web.config. What I am trying to do is I want to send a copy to the client who send an inquiry.
One copy to me and One copy to the person who sends an inquiry.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Net.Mail
Imports Microsoft.VisualBasic
Public Class EmailAdmin
Public Function SendMail(ByVal FromMail As String, ByVal EmailBody As String) As MailMessage
Const ToAddress As String = "myemail@hostfromwebconfig"
Dim mm As New MailMessage(FromMail, ToAddress)
mm.Subject = "INQUIRY FROM WEBSITE"
mm.Body = EmailBody
mm.IsBodyHtml = False
Return mm
End Function
Public Function SendInquirer(ByVal Inq_Name As String, ByVal ToInquirer As String, ByVal Tick As String) As MailMessage
Const AdminEmail As String = "myemail@hostfromwebconfig"
Dim MailMessage As String = "WELCOME " & Inq_Name & "," & _
"<p>Your Inquiry has been forwarded and will be reviewes</p>" & _
"YOUR TICKET NUMBER : " & Tick & " " & _
"Thank for sending an inquiry this will help us improve our service to you" & _
"Regards," & _
"Miletrix Trading Inc." & _
"Please do not reply this is server generated email. Thank You"
Dim inq_mail As New MailMessage(AdminEmail, ToInquirer)
inq_mail.Subject = "THANKS FOR INQUIRING"
inq_mail.Body = MailMessage
inq_mail.IsBodyHtml = False
Return inq_mail
End Function
End Class
This will trigger the send
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim CLS_Connect As New WebConnection
Dim CLS_MailAdmin As New EmailAdmin
Dim DS_Connect As New DataSet
Dim SendMail As New SmtpClient
'Dim STR_INS_Insert As String
If Page.IsValid Then
valCaptcha.Visible = True
valCaptcha.Text = "YOUR INQUIRY SUCCESSFULLY SUBMITTED"
valCaptcha.ForeColor = Drawing.Color.Blue
SendMail.Send(CLS_MailAdmin.SendMail(txtEmail.Text, txtInquiry.Text))
SendMail.Send(CLS_MailAdmin.SendInquirer(txtName.Text, txtEmail.Text, GenerateTicket()))
txtEmail.Text = ""
txtInquiry.Text = ""
txtName.Text = ""
Else
valCaptcha.Visible = True
valCaptcha.Text = "INVALID CAPTCHA CODE"
valCaptcha.ForeColor = Drawing.Color.Red
End If
End Sub
It practically sends to my email… see the config…
but not to the inquirer’s email
Back to your question…are the smtp server settings in web.config correct? Incorrect settings can allow local mail to go through but fail when sending to another server.
great such effect the tools send the mail first you can add
system.net.mail
then web.config create the connection the and local host name and username and password name
then define the alias of the connection in the code then work your code manually send the mail
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim CLS_MailAdmin As New EmailAdmin
Dim SendMail As New SmtpClient
Dim strGENTick As String
'Dim STR_INS_Insert As String
If Page.IsValid Then
valCaptcha.Visible = True
valCaptcha.Text = "YOUR INQUIRY SUCCESSFULLY SUBMITTED"
valCaptcha.ForeColor = Drawing.Color.Blue
strGENTick = GenerateTicket()
CLS_MailAdmin.SaveInquiry(strGENTick, txtName.Text, txtEmail.Text, txtInquiry.Text, Now)
Dim SmtpClient As New SmtpClient("[I][B]ip address[/B][/I]")
SmtpClient.Credentials = New Net.NetworkCredential("username", "password")
SmtpClient.Send(CLS_MailAdmin.SendInquirer(txtName.Text, txtEmail.Text, strGENTick))
txtEmail.Text = ""
txtInquiry.Text = ""
txtName.Text = ""
Else
valCaptcha.Visible = True
valCaptcha.Text = "INVALID CAPTCHA CODE"
valCaptcha.ForeColor = Drawing.Color.Red
End If
End Sub
This where you hit send.
Public Function SendInquirer(ByVal Inq_Name As String, ByVal ToInquirer As String, ByVal Tick As String) As MailMessage
Dim MailMessage As String = "<p>WELCOME " & Inq_Name & ",</p>" & _
"<p>Your Inquiry has been forwarded and will be reviewed</p>" & _
"<br /><br />" & _
"<p>YOUR TICKET NUMBER : " & Tick & "</p> " & _
"<br /><br />" & _
"<p>Thank you for sending an inquiry this will help us improve our service to you </p>" & _
"<br />" & _
"<p>Regards,</p>" & _
"<p>COMPANY NAME</p>" & _
"<em>Please do not reply this is server generated email. Thank You </em>"
Dim inq_mail As New MailMessage("email admin", ToInquirer)
inq_mail.Subject = "THANKS FOR INQUIRING"
inq_mail.Body = MailMessage
inq_mail.IsBodyHtml = True
Return inq_mail
End Function
THEN THE MESSAGE
Experiment more… Thanks for the replies of nice people before the reply of the above.