Saturday, January 1, 2011

Send email to gmail account in ASP.Net

Hi guys,
I am very excited to share with you how to send email to gmail account in ASP.Net, I will try to explain all attribute,Methods and setting in details.

First of all we are going to configure gmail account setting in webconfig file,


Attribute

  • deliveryMethod: Specifies the delivery method for e-mails.
  • from: Specifies the from address for e-mails
  • configsource: I will explain in last paragraph of this article.
  • port: specifies the port of the server.
deliveryMethod:
  • specifiedPickupDirectory: Configures the local directory for a Simple Mail Transport Protocol (SMTP) server.
  • network: Configures the network options for an external SMTP server.

we must set Port "587" in webconfig and also set User Id and password of gmail account which you want to send email, Host name should be "smtp.gmail.com".

Second step you need to write code of server side in any events.


Snippetyou also need to declared System.Net.Mail namespace by using keyword.
I want to share one more interesting thing in Configuration section. you can create a separate file of Smpt.config ( you can use another name of .config file). you can plug that file in web.config file by
configsource attribute in smtp tag.

No comments:

Post a Comment