Skip to main content

Posts

Showing posts from June, 2010

How to Read Mails from Outlook and Checking for particular User Mail

Microsoft.Office.Interop.Outlook .Application oApp; Microsoft.Office.Interop.Outlook._NameSpace oNS; Microsoft.Office.Interop.Outlook.MAPIFolder oFolder; Microsoft.Office.Interop.Outlook._Explorer oExp; oApp=new Microsoft.Office.Interop.Outlook.Application(); oNS = (Microsoft.Office.Interop.Outlook._NameSpace)oApp.GetNamespace("MAPI"); oFolder=oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders. olFolderInbox); oExp = oFolder.GetExplorer(false); oNS.Logon(Missing.Value, Missing.Value, false, true); Microsoft.Office.Interop.Outlook.Items items = oFolder.Items; //checking for unread mails foreach (Microsoft.Office.Interop.Outlook .MailItem mail in items) { if (mail.UnRead == true) { //Paste the code for already opened mails if (mail.SenderName.Trim() == "crozzX") { //Past

How to store Excel data in Gridview

Import System.Data.OleDb(using System.Data.OleDb)in code behind file Then in button onclick event write, OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\status.xls;Extended Properties=Excel 8.0"); OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$]", connection); OleDbDataReader dr; connection.Open(); dr = command.ExecuteReader(CommandBehavior.CloseConnection); DataTable excelData = new DataTable("ExcelData"); excelData.Load(dr); GridView1.DataSource = excelData; GridView1.DataBind();