How to send mail in asp.net using gmail smtp server

How to send mail in asp.net using gmail smtp server 1
Disclosure: We sometimes use affiliate links in our content. This won’t cost you anything but it helps us to offset our operative costs. Thanks for your support!

An simple method to send mail in asp.net using your own gmail account. Gmail provides you SMTP and POP access to sending and receiving mails. If you are not having smtp server to send mails than gmail is a good solution to send mail using Asp.net application.

First Thing we have to do is declare a namespace System.Web.Mail. To create a mail object, you need to create an instance of MailMessage. MailMessage contains properties such as To, Subject, BCC, CC etc. After that you have to set authentication, port, username and password. Another important thing is to run STARTTLS. STARTTLS is a command to initiate SSL handshake and switch to protection mode.

Namespace for sending mail in .NET using gmail.com

<%@ Import Namespace="System.Web.Mail" %>

Here comes the example for sending mail in asp.net using gmail


Above example must work in both local and also in server without any access problem and issues. Especially with GoDaddy server.

You get how much for free at WPX
ADVERTISEMENT
Related Post
Get it done on Fiverr
ADVERTISEMENT
Also Read  Import/Upload Image by URL Easily to your WordPress
Leave a Reply

Your email address will not be published.