ASP.Net Send mail

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

Advertisements

About Vijay Modi

Having 12+ years of experience in web application development. Expertise in various domains like E-Commerce, E-Learning, Insurance. I have expertise in web application development, window application development, Performance improvement, bug fixing etc. I have worked on various Microsoft technologies including ASP.Net, MVC, WebApi, WCF, Entity Framework, WPF, Window Application Development, AWS, Azure, AngularJS 2.0 / 1.5.2, .NetCore framework, jQuery. I am believing in quality work and achieving deadlines. Also like to work on new technologies and quick learner.
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

One Response to ASP.Net Send mail

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s