Sub Send2Mail(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim objMail As New MailMessage()
objMail.To.Add("test@test.com")
objMail.From = New MailAddress(strEmail.Text)
objMail.Priority = MailPriority.Normal
objMail.Subject = strSubject.Text
objMail.IsBodyHtml = False
objMail.Body = "Name : " + strName.Text + vbNewLine + "Email : " + strEmail.Text + vbNewLine + "Message : " + strYourMsg.Text
Dim smtp As New SmtpClient("xx.xx.xx.xx")
smtp.Port = "25"
smtp.UseDefaultCredentials = False
smtp.Send(objMail)
strMessage.Text = "<p id='feedback'>- Thanks for your kind message.</p>"
feedbackForm.Visible = False
Catch ex As Exception
strMessage.Text = "<p id='feedback'>- Error: " & ex.Message & "</p>"
End Try
End Sub
ISO scrip in asp:
<%
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "tester@test.com"
objMessage.To = "test@test.com"
objMessage.TextBody = "cdo message"
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xx.xx.xx.x"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
If Err <> 0 Then
Response.Write "An error occurred: " & Err.Description
else
Response.Write "Successfully Sent"
End If
%>
Some hosting companies require you send to "smtp.domain.com", with SMTP authentication, some require you send to "localhost".