views:

14

answers:

1
  private List<UnreadEmails> GetEmailsFromFolder(string folderName)
    {
        List<UnreadEmails> emails = null;

        object missing = System.Reflection.Missing.Value;

        try
        {
            Outlook.MAPIFolder fldEmails = null;
            emails = new List<UnreadEmails>();
            Outlook._Application outlookObj = new Outlook.Application();
            if (folderName == "Default")
            {
                fldEmails = (Outlook.MAPIFolder)outlookObj.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            }

            else
            {
                Outlook.MAPIFolder emailFolder = (Outlook.MAPIFolder)
                    outlookObj.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

                foreach (Outlook.MAPIFolder subFolder in emailFolder.Folders)
                {
                    if (subFolder.Name == folderName)
                    {
                        fldEmails = subFolder;
                        break;

                    }
                }
            }

            foreach (Microsoft.Office.Interop.Outlook._MailItem mailItem in fldEmails.Items)
            {
                if (mailItem.UnRead)
                {
                    UnreadEmails mail = new UnreadEmails();
                    {
                        mail.SenderName = (mailItem.UnRead == false) ? string.Empty : mailItem.SenderName;
                        mail.SenderAddress = (mailItem.UnRead == false) ? string.Empty : mailItem.SenderEmailAddress;
                        mail.Subject = (mailItem.UnRead == false) ? string.Empty : mailItem.Subject;


                            mail.BodyContent = MessageBox.Show(mailItem.Body);



                        mail.Attachment = "View Attachments";
                        emails.Add(mail);
                    }
                }
            } 

i wrote above method to import unread mail details to data gride from outlook 2007. it is working perfectlly but because mail.BodyContent = MessageBox.Show(mailItem.Body); that code it give mail body without stopping what i need to do is i need to open perticuler body when i click relavent button in the data gride .. pls tell me how can i do it i am haveing buttons as mail body column thank you

A: 

MessageBox.Show returns a DialogResult. I don't understand what you are trying to do. Could you please be more precise ?

hoang
ok friend thanx for ur kind attention its like this ... i need to show that dialog box in perticular buttion click (buttons are at the data grid view body column)..when we click perticular button i need to show only tha body content relevent to that mail .. not all body contents
kasunmit