by Kareem Allam
27. July 2011 18:12
- Use this in web.config
<system.net>
<mailSettings>
<smtp>
<network
host="mail.domain.com"
port="25"
userName="mail@domain.com"
password="password"
/>
</smtp>
</mailSettings>
</system.net>
- Then Use this Function (VB)
Imports System.Net.Mail
Public Function SendMail(ByVal ToMailAddress As String, _
ByVal FromMailAddress As String, _
ByVal Subject As String, _
ByVal Body As String, _
ByVal IsHTML As Boolean) As Boolean
Try
Dim objMsg As New MailMessage(FromMailAddress, ToMailAddress)
objMsg.IsBodyHtml = True
objMsg.Body = Body
objMsg.Subject = Subject
Dim smtp As New SmtpClient
smtp.Send(objMsg)
SendMail = True
Catch
SendMail = False
End Try
End Function
P.S.
This mail will be sent in HTML format. The ASP's controls that I am using are some text boxes and button send and validation controls for the required fields.
If you enjoyed this post, make sure you subscribe to my RSS feed!