Пример #1
0
        public void Carregar()
        {
            try
            {
                if (cboProjeto.Items.Count > 0)
                {
                    cboProjeto.SelectedItem = cboProjeto.Items[0];
                }

                Microsoft.Office.Interop.Outlook.MAPIFolder  inboxFolder = null;
                Microsoft.Office.Interop.Outlook.Application app         = null;
                Microsoft.Office.Interop.Outlook._NameSpace  ns          = null;
                Microsoft.Office.Interop.Outlook.MailItem    item        = null;

                app = new Microsoft.Office.Interop.Outlook.Application();
                ns  = app.GetNamespace("MAPI");
                ns.Logon(null, null, false, false);
                inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

                for (int i = 1; i <= inboxFolder.Items.Count; i++)
                {
                    item = (Microsoft.Office.Interop.Outlook.MailItem)inboxFolder.Items[i];
                    dgvInbox.Rows.Add(item.ToString(), item.SenderName, item.Subject, item.LastModificationTime.ToShortDateString(), item.Body.Replace("\r\n\r\n", "\r\n"));
                }

                this.ShowDialog();
            }
            catch (System.Exception ex)
            {
                WinControls.ApresentarErro(AssistErroException.TratarErro(ex));
            }
        }