forum

Home / DeveloperSection / Forums / How to fetch Outlook email body using C#?

How to fetch Outlook email body using C#?

Anonymous User 5822 14-Nov-2013

I am trying to make a function that fetches the body of an email with a given search criteria. When I fetch items from the mailbox and try to get the body, it only writes part of the body. I want ALL text from the body instead. How can I do this? This is what I have so far:

Outlook.Application myApp = new Outlook.Application();
        const string PR_HAS_ATTACH = "http://schemas.microsoft.com/mapi/proptag/0x0E1B000B";
        // Obtain Inbox
        Outlook.Folder folder = myApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox) as Microsoft.Office.Interop.Outlook.Folder;
        Outlook.Table table = folder.GetTable(Microsoft.Office.Interop.Outlook.OlTableContents.olUserItems);
        // Remove default columns
        table.Columns.RemoveAll();
        // Add using built-in name
        table.Columns.Add("Subject");
        table.Columns.Add("ReceivedTime");
        table.Sort("ReceivedTime", Microsoft.Office.Interop.Outlook.OlSortOrder.olDescending);
        // Add using namespace
        // Date received
        table.Columns.Add("urn:schemas:httpmail:textdescription");
        while (!table.EndOfTable)
        {
            Outlook.Row row = table.GetNextRow();
            if (row["Subject"].ToString().ToLower().Contains(subject.Text.ToLower()) && row["ReceivedTime"].ToString().Contains(cellCreationDate))
            {                   
                body.Text = row["urn:schemas:httpmail:textdescription"].ToString();
            }
        }


c# c# 
Updated on 14-Nov-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By