Jan 13, 2014

File decryption using c#.net

c# code:          

  string InputFile = Application.StartupPath +"\\ encrptsofttechsolving.xml ";   // this is excel file, i.e I  wanna to deencrypt
                string OutputFile = = Application.StartupPath +"\\softtechsolving.xls ";   // softtechsolving is file name after decryption of  encrptsofttechsolving.xml
            XmlDocument XDoc1 = new XmlDocument();
            try
            {
                string password = @"xxxxxxx"; // Your Key Here

                UnicodeEncoding UE = new UnicodeEncoding();
                byte[] key = UE.GetBytes(password);

                FileStream fsCrypt = new FileStream(inputFile, FileMode.Open);

                RijndaelManaged RMCrypto = new RijndaelManaged();

                CryptoStream cs = new CryptoStream(fsCrypt,
                    RMCrypto.CreateDecryptor(key, key),
                    CryptoStreamMode.Read);

                FileStream fsOut = new FileStream(outputFile, FileMode.Create);

                int data;
                while ((data = cs.ReadByte()) != -1)
                    fsOut.WriteByte((byte)data);

                fsOut.Close();
                cs.Close();
                fsCrypt.Close();

            }
            catch (Exception ex)
            {
                //MessageBox.Show("DecryptFile failed!", "Error");
            }Namespace:
Adding
using System;
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.IO;
using System.Security.Cryptography;

using System.Xml;

File encryption using c#.net

try
            {

                string InputFile = Application.StartupPath + "\\softtechsolving.xls";   // this is excel file, i.e I  wanna to encrypt
                string OutputFile = = Application.StartupPath + "\\encrptsofttechsolving.xml";   // encrptsofttechsolving is file name after encryption file name                                                                                                saved that name  
                string password = @"xxxxx"; // Your Key Here
                UnicodeEncoding UE = new UnicodeEncoding();
                byte[] key = UE.GetBytes(password);

                FileStream fsCrypt = new FileStream(outputFile, FileMode.Create);

                RijndaelManaged RMCrypto = new RijndaelManaged();

                CryptoStream cs = new CryptoStream(fsCrypt,
                    RMCrypto.CreateEncryptor(key, key),
                    CryptoStreamMode.Write);

                FileStream fsIn = new FileStream(inputFile, FileMode.Open);

                int data;
                while ((data = fsIn.ReadByte()) != -1)
                    cs.WriteByte((byte)data);


                fsIn.Close();
                cs.Close();
                fsCrypt.Close();
                MessageBox.Show("Backup Done", "Demo Software");
            }
            catch
            {
                MessageBox.Show("Encryption failed!", "Error");
            }
Namespace:
Adding
using System.Xml;
using System.IO;
using System.Security.Cryptography;
using System.Xml.Linq;
using System.Xml.Serialization;

using System.Data.SqlClient;

Jan 8, 2014

How to send mail to another email id through gmail provider using c#.net



C# Code:

MailMessage Msg = new MailMessage();
            // Sender e-mail address.
            string FromMail = "noreplysofttechsolving@gmail.com";
            string Password = "xxxxxx"; //sender email password
            Msg.From = new MailAddress(FromMail);
            // Recipient e-mail address..
            string ToMail = txtEmail.Text;
            Msg.To.Add(ToMail);
            string MsgBody = "Thank you!!!!";
            AlternateView htmlMsgView = AlternateView.CreateAlternateViewFromString(MsgBody, null, MediaTypeNames.Text.Html);
            Msg.Subject = "SoftTechSolving";
            //Msg.Body = MsgBody;
            Msg.AlternateViews.Add(htmlMsgView);
            // your remote SMTP server IP.
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Credentials = new System.Net.NetworkCredential(FromMail, Password);
            smtp.EnableSsl = true;
            smtp.Send(Msg);
            Msg = null;

How to send mail to another email id using C#.Net

C# Code:

MailMessage Msg = new MailMessage();
        string FromMail = "noreply@softtechsolving.com";
        string Password = "XXXXXXX";   //”XXXXXX” is email id password
        Msg.From = new MailAddress(FromMail);
        // Recipient e-mail address..
        string ToMail = txtEmail.Text;
        Msg.To.Add(ToMail);
        string MsgBody = "welcome to softtechsolving…";
        AlternateView htmlMsgView = AlternateView.CreateAlternateViewFromString(MsgBody, null, MediaTypeNames.Text.Html);
        Msg.AlternateViews.Add(htmlMsgView);
        Msg.Subject = "softtechsolving";
        Msg.Body = MsgBody;

        //send the message
        SmtpClient smtp = new SmtpClient("mail.softtechsolving.com");

        //to authenticate we set the username and password properites on the SmtpClient
        smtp.Credentials = new NetworkCredential(FromMail, Password);
        smtp.Send(Msg);

How to send mail to another email id with attachment file

C# Code:

Attachment at = new Attachment(Server.MapPath(MemberPic)); //for attached file.... 'MemberPic' is file path , is string format…
                    MailMessage Msg = new MailMessage();
                    string FromMail = "support@softtechsolving.com";
                    string Password = "XXXXXX"// "XXXXXX" is sender password…
                    Msg.From = new MailAddress(FromMail);
                    // Recipient e-mail address..
                    string ToMail = "softtechsolving@gmail.com";   //Receiver email id…
                    Msg.To.Add(ToMail);
                    string MsgBody = "Thank you…, Softtechsolving.. plz find attached file..";
                    AlternateView htmlMsgView = AlternateView.CreateAlternateViewFromString(MsgBody, null, MediaTypeNames.Text.Html);
                    Msg.AlternateViews.Add(htmlMsgView);
                    Msg.Subject = "Soft-Tech Solving;
                    Msg.Body = MsgBody;

                    //send the message
                    SmtpClient smtp = new SmtpClient("mail.softtechsolving.com");

                    //to authenticate we set the username and password properites on the SmtpClient
                    smtp.Credentials = new NetworkCredential(FromMail, Password);
                    Msg.Attachments.Add(at);
                    smtp.Send(Msg);

How to Send message to mobile no using c#

c# Code:

string ContactNo = "8343094272"; // to mobile no
                string MessageText = "Welcome to Softtechsolving"; // your message
                string strUrl = string.Format("http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=softtechsolving@gmail.com:soft@123&senderID=TEST SMS&receipientno={0}&msgtxt={1}&state=4", ContactNo, MessageText);
                WebRequest request = HttpWebRequest.Create(strUrl);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream s = (Stream)response.GetResponseStream();
                StreamReader readStream = new StreamReader(s);
                string dataString = readStream.ReadToEnd();
                response.Close();
                s.Close();
                readStream.Close();