none
outlook add in question RRS feed

  • Question

  • not sure if this is the right forum if not please direct me to the correct forum

    I am using outlook 2010 and visual studio 2010 pro.

    I have this code

                Outlook.Table table = folder.GetTable("", Outlook.OlTableContents.olUserItems);             Array tableArray = table.GetArray(table.GetRowCount()) asArray;             for (int i = 0; i <= tableArray.GetUpperBound(0); i++)             {                 for (int j = 0; j <= tableArray.GetUpperBound(1); j++)                 {                     Debug.WriteLine(tableArray.GetValue(i, j));                    var mailItem = tableArray.GetValue(i, j);                 }             }

    that i found from the net, but what i dont know how to do is to get the accually mail item from this code,

    the output of this code is:

    IPM.Note
    00000000BF6A3470037B8746B5B7DA6039C12B21841C1601
    Returned mail: could not connect and send the mail to comcat.net
    4/3/2012 12:06:22 PM
    4/3/2012 12:06:22 PM
    IPM.Note
    00000000BF6A3470037B8746B5B7DA6039C12B2184371601
    Returned mail: could not resolve target DNS
    4/3/2012 12:07:26 PM
    4/3/2012 12:07:26 PM

    I assume that this "00000000BF6A3470037B8746B5B7DA6039C12B2184371601" if the guid of the mail item but how can i

    get the item then look at the text data in the mail message.

     
    Wednesday, April 4, 2012 5:50 AM

Answers

All replies

  • what you got printed are just default properties of items (here: mailitem), which are MessageClass, EntryID, Subject, etc. (http://msdn.microsoft.com/en-us/library/bb226714(v=office.12).aspx). If you want to retrieve outlook's item for each row in table, use following code:

    while(!table.EndOfTable)

    {

    var row = table.GetNextRow();

    Application.Session.GetItemByItemId(row["EntryID"])

    }

    Wednesday, April 4, 2012 7:22 AM
  • Hello,

        That article is from 2007 I would like one for outlook 2010.

    Error 1 'Microsoft.Office.Interop.Outlook.NameSpace' does not contain a definition for 'GetItemByItemId' and no extension method 'GetItemByItemId' accepting a first argument of type 'Microsoft.Office.Interop.Outlook.NameSpace' could be found (are you missing a using directive or an assembly reference?) ThisAddIn.cs 48 45 FirstOutlookAddIn

    errors here  Application.Session.GetItemByItemId(row["EntryID"]);

                Outlook.Table table = folder.GetTable("", Outlook.OlTableContents.olUserItems);
                while(!table.EndOfTable)
                    {
                            var row = table.GetNextRow();
                            Application.Session.GetItemByItemId(row["EntryID"]);
                     }
    

    • Edited by Tdar Wednesday, April 4, 2012 11:24 AM
    Wednesday, April 4, 2012 11:24 AM
  • outlook is compatible forward, so what is described for 2007 will also work for 2010. If you insist, look yourself for API documentation for 2010. As for second problem - use intellisense, you will find GetItemByID method.

    Wednesday, April 4, 2012 11:37 AM
  • Or rather Namespace.GetItemFromID.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Wednesday, April 4, 2012 5:39 PM
  • hahaha, i would get it right on third try ;-)
    Thursday, April 5, 2012 6:11 AM