Saturday, 26 March 2016

Send Email Through GoDaddy Server to other Email Account in Asp.net


Suppose in your website you have a contact us or career page in which user may send his data or can contact you and you want that data on y our Gmail, Outlook, Hotmail or other email account. First of all look at the form
In the above form if you want to receive user data on you different email accounts then one thing you should consider in your mind.

 Web browser is not going to directly send data in your email account (email will be send through other email account) , So you will have to give an interface through which your server can send data from client side.

So how you will do it in Asp.net ? for this you will have to go through following steps.

1. add name space
                         using System.Net;
                         using System.Net.Mail;
2. On click event of submit button write following code.
 1. Create an object of MailMessage class like this

         MailMessage msg = new MailMessage(); 
in this object you will get many properties and method to use in sending email

            string email = "Write Here The email ID on which you want to Receive Data";
            string name = "Email ID";
// Now mainmessage string will contain data in prescribe format in which you want 
            string mainmessage = "<html><body>Name : " + TextBox1.Text + "<br />" + "Email ID: : " +     TextBox2.Text + "<br />" + "Contact No : " + TextBox3.Text + "<br />" + "Website Name : " + TextBox4.Text + "<br />" +
                "Message : " + TextBox5.Text + "<br /></body></html>";
            MailMessage msg = new MailMessage();
            msg.Subject = "Message or Feedback From a User";
            msg.Body = mainmessage;
            msg.IsBodyHtml = true;
            msg.Priority = MailPriority.High;
            msg.From = new MailAddress(TextBox2.Text);
            msg.To.Add(new MailAddress(email.Trim(), name));
            SmtpClient smptc = new SmtpClient(); // Here SMTP Client object is created
            smptc.Host = "smtpout.asia.secureserver.net";// here SMTP interface Address is passed
            smptc.Port = 25;// Use port No 25
            smptc.UseDefaultCredentials = false;
            smptc.EnableSsl = false;
            smptc.DeliveryMethod = SmtpDeliveryMethod.Network;
            NetworkCredential credentials = new NetworkCredential("Write Email or User name of GoDaddy Email Account", "Password here");
            smptc.Credentials = credentials;
            smptc.Send(msg);
            Response.Write("<script type='text/javascript'>alert('Thanks! for your feedback.')</script>");
            TextBox1.Text = "";
            TextBox2.Text = "";

Hope this would help you.

Similarly you can use Gmail and Hotmail but due to some security reason they do not like such activity.

Friday, 25 March 2016

cash handling income and expense using C#

// ------------------to check available cash ------------------------------

        private void CashHandling()
        {
            this.Refresh();
            Cursor.Current = Cursors.WaitCursor;
            string sTot = "";
            double totIncCus = 0.00;
            double totIncService = 0.00;
            double totIncomeMachine = 0.00;
            double totInc = 0.00;
            double totExp = 0.00;
            DateTime dFrdt = DateTime.Today;//DateTime.Parse(dtpNetTotal.Text);

            //Income

            string str = "Select IncDte,TotAmount from T_IncomeInv";
            Con = new OleDbConnection(dbCon());
            OleDbCommand cmd = new OleDbCommand(str, Con);
            Con.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                if (dr.IsDBNull(0) == false)
                {
                    string sDt = dr.GetValue(0).ToString();
                    DateTime dDt = Convert.ToDateTime(sDt);
                    if (dFrdt == dDt)
                    {
                        // string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;

                        sTot = dr.GetValue(1).ToString();
                        if (sTot != "")
                        {
                            totInc += Convert.ToDouble(sTot);
                        }
                    }
                }
            }
            dr.Close();
     
            // From Customer Income
            string strCus = "Select BillDate,GrandTotal from T_CustBill Where Status<>'Cancel'";
            OleDbCommand cmdCus = new OleDbCommand(strCus, Con);
            OleDbDataReader drCus = cmdCus.ExecuteReader();
            while (drCus.Read())
            {
                if (drCus.IsDBNull(0) == false)
                {
                    string sDt = drCus.GetValue(0).ToString();
                    DateTime dDt = Convert.ToDateTime(sDt);
                    if (dFrdt == dDt)
                    {
                        // string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;

                        sTot = drCus.GetValue(1).ToString();
                        if (sTot != "")
                        {
                            totIncCus += Convert.ToDouble(sTot);
                        }
                    }
                }
            }
            drCus.Close();      
            // ----------------------- Service Income ----------------------
            // From Customer Income
            string strService = "Select BillDate,NetRs from T_ServiceInv";
            OleDbCommand cmdService = new OleDbCommand(strService, Con);
            OleDbDataReader drService = cmdService.ExecuteReader();
            while (drService.Read())
            {
                if (drService.IsDBNull(0) == false)
                {
                    string sDt = drService.GetValue(0).ToString();
                    DateTime dDt = Convert.ToDateTime(sDt);
                    if (dFrdt == dDt)
                    {
                        // string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;

                        sTot = drService.GetValue(1).ToString();
                        if (sTot != "")
                        {
                            totIncService += Convert.ToDouble(sTot);
                        }
                    }
                }
            }
            drService.Close();
            //------------------------- Service Income End ----------------------
            // ----------------------- Machine Income ----------------------
            // From Customer Income
            string strMachine = "Select BillDate,NsuRs from T_QuoBillInvoice";
            OleDbCommand cmdMachine = new OleDbCommand(strMachine, Con);
            OleDbDataReader drMachine = cmdMachine.ExecuteReader();
            while (drMachine.Read())
            {
                if (drMachine.IsDBNull(0) == false)
                {
                    string sDt = drMachine.GetValue(0).ToString();
                    DateTime dDt = Convert.ToDateTime(sDt);
                    if (dFrdt == dDt)
                    {
                        // string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;

                        sTot = drMachine.GetValue(1).ToString();
                        if (sTot != "")
                        {
                            totIncomeMachine += Convert.ToDouble(sTot);
                        }
                    }
                }
            }
            drMachine.Close();
            //------------------------- Machine Income End ----------------------
         
            //
            //Expenditure
            string strExp = "Select ExpDte,TotAmount from T_ExpenditureInv";
            OleDbCommand cmdExp = new OleDbCommand(strExp, Con);
            OleDbDataReader drExp = cmdExp.ExecuteReader();
            while (drExp.Read())
            {
                if (drExp.IsDBNull(0) == false)
                {
                    string sDt = drExp.GetValue(0).ToString();
                    DateTime dDt = Convert.ToDateTime(sDt);
                    if (dFrdt == dDt)
                    {
                        // string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;

                        sTot = drExp.GetValue(1).ToString();
                        if (sTot != "")
                        {
                            totExp += Convert.ToDouble(sTot);
                        }
                    }
                }
            }
            drExp.Close();
            string SOthInc = totInc.ToString("N2");
            string Sexpense = totExp.ToString("N2");
            string SCusSpare = totIncCus.ToString("N2");
            string SMachine = totIncomeMachine.ToString("N2");
            string Sservice = totIncService.ToString("N2");
            string sNetTotal = "0.00";
            sNetTotal = ((totIncCus + totInc + totIncService + totIncomeMachine) - totExp).ToString("N2");
     
            timer1.Enabled = true;
            scrText = "Net Balance:" + sNetTotal.ToString() + "   " + "Expense:" + Sexpense.ToString() + "  " + "Other Income:" + SOthInc.ToString() + " " + "Spare:" + SCusSpare.ToString() + " " + "Invoice:" + SMachine.ToString()+" "+"Service:"+Sservice .ToString ();
           // tsslAmt.Text = scrText.ToString();
         
            Cursor.Current = Cursors.Default;
}








Dropdown Menu in Navbar

<!DOCTYPE html>
<html>
<head>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
}

li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover, .dropdown:hover .dropbtn {
    background-color: red;
}

li.dropdown {
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
    display: block;
}
</style>
</head>
<body>

<ul>
  <li><a class="active" href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li class="dropdown">
    <a href="#" class="dropbtn">Dropdown</a>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </li>
</ul>

<h3>Dropdown Menu inside a Navigation Bar</h3>
<p>Hover over the "Dropdown" link to see the dropdown menu.</p>

</body>
</html>

Tuesday, 15 December 2015

Sending Web mail in C#

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using BusinessEntities;
using DataAccessLayer;
using System.Net;
using System.Net.Mail;

namespace MultiShop
{
    public partial class FrmDemo : Form
    {
        public FrmDemo()
        {
            InitializeComponent();
        }
        OleDbConnection con;

        private string dbCon()
        {
            StreamReader sr = File.OpenText("dbcon.txt");
            string conread = sr.ReadLine();
            return conread;
        }

        private string var1 = "";
        private string var2 = "";
        private string var3 = "";
        private string var4 = "";//"25";
        private string var5 = "";//"false";
        private string var6 = "";

        private void LoadEmail()
        {
            string str = "Select ServerName,EmailID,EmailPassword,PortNo,SSLInfo from T_EmailConfig";
         
            con = new OleDbConnection(dbCon());
            OleDbCommand cmd = new OleDbCommand(str, con);
            con.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {

                 var1 = dr.GetValue(0).ToString();
                 var2 = dr.GetValue(1).ToString();
                 var3 = dr.GetValue(2).ToString();
                 var4= dr.GetValue(3).ToString();
                 var5= dr.GetValue(4).ToString();
                 var6  = dr.GetValue(1).ToString();
            }
        }


        private void FrmDemo_Load(object sender, EventArgs e)
        {
            this.progressBar1.Visible = false;
            textBox1.Focus();
            LoadEmail();
           
        }

        private void sendmail()
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter To Email id ", "Enter ID", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Focus();
                return;
            }
            if (textBox3.Text == "")
            {
                MessageBox.Show("Please enter Cc id ", "Enter ID", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox3.Focus();
                return;
            }
            if (textBox4.Text == "")
            {
                MessageBox.Show("Please enter Bcc id ", "Enter ID", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox4.Focus();
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("Please enter Subject ", "Enter ID", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox2.Focus();
                return;
            }


            try
            {
                MailMessage message = new MailMessage();
                SmtpClient client = new SmtpClient(this.var1);
                message.From = new MailAddress(this.var6);
                string[] strArray = this.textBox1.Text.Split(new char[] { ',' });
                for (byte i = 0; i < strArray.Length; i = (byte)(i + 1))
                {
                    message.To.Add(strArray[i]);
                }
                string[] StrCCArray = textBox3.Text.Split(new char[] { ',' });
                 string[] StrBCCArray = textBox4.Text.Split(new char[] { ',' });
                for (byte c = 0; c < StrCCArray.Length; c = (byte)(c + 1))
                {
                    message.CC.Add(StrCCArray[c]);
                    message.Bcc.Add(StrBCCArray[c]);
                }
                client.Port = Convert.ToInt32(this.var4);
                client.Credentials = new NetworkCredential(this.var2, this.var3);
                client.EnableSsl = Convert.ToBoolean(this.var5);              
                message.Subject = textBox2.Text;
                message.Body = richTextBox1.Text;
                Byte ii = 0;
                if (listBox1 .Items .Count !=0)
                {
                    for (ii = 0; ii < listBox1.Items.Count; ii++)
                        message.Attachments.Add(new Attachment(listBox1.Items[ii].ToString()));
                }
                message.IsBodyHtml = true;
                message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
             
                this.progressBar1.Visible = true;
                int num2 = 0;
                num2 = 5;
                this.progressBar1.Maximum = 5;
                this.progressBar1.Value = 0;
                for (int j = 0; j < num2; j++)
                {
                    this.progressBar1.Value++;
                }
                client.Send(message);
                this.progressBar1.Value = 0;
                this.progressBar1.Visible = false;
                MessageBox.Show("Mail has been sent...","Success",MessageBoxButtons .OK ,MessageBoxIcon .Information);
             
            }
            catch (Exception)
            {
                MessageBox.Show("Problem in Mail Id / Mail Server. Check your Email Server Master Setting","!Failed?",MessageBoxButtons .OK ,MessageBoxIcon .Error);
            }
            finally
            {
                Cursor.Current = Cursors.Arrow;
            }
        }


        private void btnSendMail_Click(object sender, EventArgs e)
        {
            LoadEmail();
            sendmail();

        }

        private void BtnAdd_Click(object sender, EventArgs e)
        {
            MultiShop.FrmAttachment frm = new MultiShop.FrmAttachment();
            frm.ShowDialog(this);
            if (frm.txtFile.Text.Trim() != "")
                listBox1.Items.Add(frm.txtFile.Text);
            frm.Dispose();
        }

        private void BtnRemove_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex > -1)
                listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            richTextBox1.Text = "";
            listBox1.Items.Clear();
        }

        private void FrmDemo_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel =true;
            this.Hide();

        }
    }
}

Tuesday, 18 November 2014

Extract source code (Java and XML) from Android APK File


Not getting any idea how to make good layout in Android activity or not getting how any application doing that things which you want in your project but you don’t know how to implement it in your APK File. So, I came here with new technology & new thinking which can make you crazy in android world.

Now time for backtracking…start your time to do hacking. Do you know you can get source code of Android APK file? Time to break the code..Let’s learn step by step.

In this tutorial we will learn how to convert android APK file into source code. Android .apk file is a compressed form of a file which contains Java classes (in .dex form), XML files and all necessary files. So first we will learn how to get Java source File from android apk using dex2jar and Java decompiler tools and then we will learn how to get XML source file using apktool and apkinstall tools.

To get the source code from APK file, we will need these tools:

1. dex2jar
2. java decompiler
3. apktool
4. apkinstall

Steps to get source:- 

Get Java files from APK:-

1. Rename the .apk file into .zip file (example SharedPr.apk into SharedPr.zip).
2. Extract SharedPr.zip file and copy classes.dex file from extracted folder.
3. Extract dex2jar.zip and paste classes.dex into dex2jar folder.
3. Open command prompt and change directory to the dex2jar folder. Then write dex2jar classes.dex and press enter. Now you will get classes.dex.dex2jar file in the same folder.

How To Get JAVA Code And XML Code From APK
Convert classes.dex to classes.dex.dex2jar
4. Now double click on jd-gui(Java decompiler) and click on open file. Then open classes.dex.dex2jar file from that folder. Now you will get class files and save all these class files (click on file then click “save all sources” in jd-gui) by src name.

How To Get JAVA Code And XML Code From APK
classes.dex.dex2jar will be in dex2jar folder


How To Get JAVA Code And XML Code From APK
Save All Java Files

Get XML files from APK:-

1. Extract apktool and apkinstall in a folder(Example : New Folder).
2. Put SharedPr.apk(your apk file) in same folder(i.e New Folder).

How To Get JAVA Code And XML Code From APK
Keep Android Apk File with apktool and apkinstall

3. Open the command prompt and go to the root directory(i.e New Folder).
4. Type command on command prompt: apktool d SharedPr.apk

How To Get JAVA Code And XML Code From APK
Get All XML Files In Resource Folder

5. This will generate a folder of name SharePr in current directory (here New Folder) and all XML files will be in res->layout folder.

How To Get JAVA Code And XML Code From APK
See All XML Files in new created Folder

Now you have source code. If you have any doubts please comment. Share and help others.

Saturday, 15 November 2014

how to set ten digit Seecrate code in c#

 private void seeCode()
        {
            label1.Text = "";
            DateTime dAdt = DateTime.Parse(dateTimePicker1.Text);
            Int32 fdd = dAdt.Day;//.ToString();
            Int32 fmm = dAdt.Month;//.ToString();
            int adm1 = Convert.ToInt32(fmm);
            Int32 fyyyy = dAdt.Year;//.ToString();
            string adm = fdd .ToString ()+ adm1.ToString() + fyyyy.ToString();

            MessageBox.Show(adm.ToString());
            textBox1.Text = adm.ToString();
            char[] chararray = this.textBox1.Text.ToCharArray();
            Array.Reverse(chararray);
            textBox2.Text = "";
            for (int i = 0; i <= chararray.Length - 1; i++)
            {
                textBox2.Text += chararray.GetValue(i);
            }
           // textBox2.Text = "";

            string sam = textBox2.Text;
           

            int num =Convert .ToInt32 (sam); //Convert.ToInt32(Math.Truncate(sma));//Convert.ToInt32(sma);
           
            string code;

            while (num != 0)
            {
                int r = num % 10;


                switch (r)
                {
                    case 1:
                        code = "One";
                        break;
                    case 2:
                        code = "Two";
                        break;
                    case 3:
                        code = "Three";
                        break;
                    case 4:
                        code = "Four";
                        break;
                    case 5:
                        code = "Five";
                        break;
                    case 6:
                        code = "Six";
                        break;
                    case 7:
                        code = "Seven";
                        break;
                    case 8:
                        code = "Eight";
                        break;
                    case 9:
                        code = "Nine";
                        break;
                 
                    default:
                        code = "Zero";
                        break;

                }

               
                label1.Text = label1.Text + code;
                int q = num / 10;

                num = q;

               
            }

        }

how to set back color in web form using c#.net windows applications

you can write this code on example.cs

initialize component

 Color color = ColorTranslator.FromHtml("#CFE0F7");
            this.BackColor = color;