public void GetDataFromAccessDb()
        {
            string  sql = @"SELECT * FROM T_EmailInfo";
            DataSet ds  = _accessDBConnection.GetDataFromDb(sql);
            var     dt  = ds.Tables[0];

            foreach (DataRow dtRow in dt.Rows)
            {
                string to      = dtRow["To"].ToString();
                string cc      = dtRow["CC"].ToString();
                string subject = dtRow["Subject"].ToString();
                string body    = dtRow["Body"].ToString();
                insertIntoExcel(to, cc, subject, body);
            }
            _accessDBConnection.CloseDbConnection();
        }
Exemple #2
0
        public void readEmailByFolderAndSaveToDb()
        {
            Outlook.Application application = new Outlook.Application();
            Outlook.NameSpace   ns          = application.GetNamespace("mapi");
            mainbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.MAPIFolder targetFolder  = mainbox.Folders[ConfigureHelper.GetAppSettingsKeyValue(Constants.FolderA)];
            Outlook.MAPIFolder processFolder = mainbox.Folders[ConfigureHelper.GetAppSettingsKeyValue(Constants.ProcessFolder)];

            int loopTime = targetFolder.Items.Count;

            for (int i = 0; i < loopTime; i++)
            {
                item = targetFolder.Items.GetFirst();
                SaveEmailInfo(item);
                targetFolder.Items.GetFirst().Move(processFolder);
            }
            _accessDBConnection.CloseDbConnection();
        }