Thursday, 28 March 2013

Send Email with attachment In Asp .Net with c#

Send Email with attachment In Asp .Net with c#       

 string filePath  ="C:\\abc.doc";
        string senderEmailid="senderemailid@gmail.com";
        string senderPassword="password";
        string recieverEmailid="recievermailid@gmail.com";
        var client = new SmtpClient("smtp.gmail.com", 587)
        {
            Credentials = new NetworkCredential(senderEmailid, senderPassword),
            EnableSsl = true
        };

        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(senderEmailid,             recieverEmailid);

        mail.Attachments.Add(new Attachment(Server.MapPath(filePath)));

        mail.Subject ="Subject of Mail"
        mail.Body ="<b>Hai</b>";
   
       
        mail.IsBodyHtml = true; // To make html

        client.Send(mail);

Sunday, 24 March 2013

Method to Convert Number to Words Asp .Net C#

Method to Convert Number to Words Asp .Net C#

 private string NumberToWords(int number)
    {
        if (number == 0)
            return "zero";

        if (number < 0)
            return "minus " + NumberToWords(Math.Abs(number));

        string words = "";
        if ((number / 1000000000) > 0)
        {
            words += NumberToWords(number / 1000000000) + " Billion ";
            number %= 1000000000;
        }

        if ((number / 10000000) > 0)
        {
            words += NumberToWords(number / 10000000) + " Crore ";
            number %= 10000000;
        }

        if ((number / 1000000) > 0)
        {
            words += NumberToWords(number / 1000000) + " million ";
            number %= 1000000;
        }


        if ((number / 100000) > 0)
        {
            words += NumberToWords(number / 100000) + " lakh ";
            number %= 100000;
        }


        if ((number / 1000) > 0)
        {
            words += NumberToWords(number / 1000) + " thousand ";
            number %= 1000;
        }

        if ((number / 100) > 0)
        {
            words += NumberToWords(number / 100) + " hundred ";
            number %= 100;
        }

        if (number > 0)
        {
            if (words != "")
                words += "and ";

            var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
            var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

            if (number < 20)
                words += unitsMap[number];
            else
            {
                words += tensMap[number / 10];
                if ((number % 10) > 0)
                    words += "-" + unitsMap[number % 10];
            }
        }

        return words;
    }



Example :

NumberToWords(33333); //Calling Method

Output

thirty-three thousand three hundred and thirty-three

IE7 Issues Text Indent

                 Unfortunately IE 7 is still widespread among the users hence while theming we have to give special importance to the grea...