I have write a function to send mail in asp.net. Sending mail is an important feature of each and every project. And so I write this article and providing one function to send mail.
Public Function SendMail(ByVal Sender As String, ByVal Receiver As String, ByVal Subject As String, _
ByVal CC As String, ByVal BCC As String, ByVal Message As String)
Dim NewMailToUser As New MailMessage
NewMailToUser.To = Receiver
NewMailToUser.From = Sender
If Not (CC = String.Empty) OrElse Not IsNothing(CC) Then
NewMailToUser.Cc = CC
End If
If Not (BCC = String.Empty) OrElse Not IsNothing(BCC) Then
NewMailToUser.Bcc = BCC
End If
NewMailToUser.Subject = Subject
NewMailToUser.BodyFormat = MailFormat.Html
NewMailToUser.Body = Message
SmtpMail.SmtpServer = String.Empty 'SMTP server name or address. You have to change depends on your SMTP server
SmtpMail.Send(NewMailToUser)
End Function
You can use this function to send mail and you can call it as following:
SendMail(strSender, strTo, strSubject, Nothing, Nothing, strMessage)
Enjoying Programming,
Regards,
Vijay Modi
Wednesday, February 18, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment