Skip to main content

Send E-Mail using ASP.NET C#

Hello World!!

Today I would I like to share my knowledge regarding “Send an E-Mail using ASP.Net C#”

Using C#.NET it’s quite easy to send e-mail. I have used this code to send e-mail viva godaddy.com mail server.


For “web.config” file, you may follow these lines of code, this code works fine for me after trying 
many other options.

Pre Requirement is you have to create a email address for your domain name for example if your domain name is xyzblog.com then your email should be no-reply@xyzblog.com.

I have tested this on localhost.

<system.net>
    <mailSettings>
      <smtp from="no-reply@Mydomain.com">
        <network host="smtpout.secureserver.net" userName="Myemail@mydomain.com" password="Mypassword"/>
      </smtp>
    </mailSettings>
  </system.net>

if you want to use Gmail.com follow these code lines.

<system.net>
    <mailSettings>
      <smtp from="iam@gmail.com">
        <network host="smtp.gmail.com" port="25" userName="im@gmail.com" password="mypassword" enableSsl="true"/>
      </smtp>
    </mailSettings>
  </system.net>

In code behind.
using System.Net.Mail;
bool SendEmail(string toAddress,string subject,String PersonName)
{
        try
        {
            MailMessage MM = new MailMessage();
            MM.From = new MailAddress("Myemail@mydomain.com", PersonName);
            MM.To.Add(new MailAddress(toAddress));
            MM.Subject = subject;
      MM.Body = "<br />Thank you!</span>;
            MM.IsBodyHtml = true;
            SmtpClient mySMTP = new SmtpClient();
            mySMTP.Send(MM);
        }
        catch 
        {
            return false;
            
        }

        return true;
}


Comments

Popular posts from this blog

Font identifier and Unicode converter for Hindi

Font identifier and Unicode converter for Hindi Fonts are used to represent text in document. Fonts are mainly two kind non-Unicode and Unicode fonts. Complex scripts like Hindi and other Asian languages well represented in Unicode fonts. There are some other ways to write these languages for e.g we can use ASCII/ISCII codes to represent different characters of Hindi, but there are large numbers of characters in Hindi script as compared to English. Therefore, we always need multiple ASCII/ISCII encoded characters combination to represent a single character of Hindi Script. One major problem in these ASCII encoding based fonts is that we cannot easily transfer text from one system to another. The system must have these text fonts. There is hundreds of ASCII/ISCII encoding based fonts which are used to write Hindi text. New software systems are based on Unicode fonts.                   ...

Binary Search Tree in ASP .Net

Binary Search Tree in ASP .Net To create Binary Search Tree(BST) in Asp.net application   first you need to create a Node class. Something like following : class Node {     public String data;     public int freq = 0;     public Node left, right;     public Node()     { }     public Node( String data)     {         this .data = data;         left = null ;         right = null ;     } } Next You need to create a class including different functions.Like class BinaryTreeImp {     Node root;     String outputfreq = "" ;     static int count = 0;     public BinaryTreeImp()     {      ...

Hindi to Punjabi Machine Translation System

The Hindi To Punjabi Machine Translation System has been developed using Direct/Rule based Approach by Dr.Vishal Goyal and Dr. G.S Lehal. Various large size Lexicon resources  have been used to map Source and Target language words.  In general, if the two languages are structurally similar, in particular as regards lexical correspondences, morphology and word order, the case for abstract syntactic analysis seems less convincing. Since the present research work deals with a pair of closely related language, so the direct translation system is the obvious choice. The overall system architecture shown below, is adopted for Hindi to Punjabi Machine Translation System. The system is divided into three stages: Preprocessing, Translation Engine, and Post Processing stage. Following is the description of various steps of this architecture.  PreProcessing   The pre-processing stage is a collection of operations that are applied on input  data to make it pr...