none
Getting error while working with .oft file RRS feed

  • Question

  • myitem = ol.CreateItemFromTemplate("D:\my.oft", Type.Missing)

     here i m getting error : 

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    Thursday, October 13, 2011 8:54 AM

Answers

  • Aside from the code in the last 2 lines, you need to do what I told you to do. You need to cast your item that you create with CreateItemFromTemplate(), which returns an Object, to a MailItem.
     
    Aside from that, did you modify "P.2" at all? Is it still called "P.2"? Is there a control on "P.2" named "TextBox2"? If so you need to set its value to a string, not to a number.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "binal trivedi" <=?utf-8?B?YmluYWwgdHJpdmVkaQ==?=> wrote in message news:940f4f1e-9e91-4c6e-b963-eeffb8a6f9db...

    here i m attaching whole code. pls check it. 

     

    Dim myapp As Application

            Dim myitem As MailItem

            Dim mypages As Pages

     

            myapp = CreateObject("Outlook.Application")

            myitem = myapp.CreateItemFromTemplate("D:\my.oft")

            myitem.Display()

            mypages = myitem.GetInspector.ModifiedFormPages("P.2")

            mypages.Controls("TextBox2").value = 234

    last 2 lines giving me error. 

    i want to access controls of .oft file to display data.& i m using vb.net .


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Wednesday, October 26, 2011 1:17 PM
    Monday, October 17, 2011 2:07 PM

All replies

  • i want to display data on .oft file. which is inputed from vb.net Form(windows appliacation).
    Thursday, October 13, 2011 8:56 AM
  • How is myitem declared? Is it as object or ContactItem?
     
    If as ContactItem you need to cast it to that. The return value from CreateItemFromTemplate is object.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "binal trivedi" <=?utf-8?B?YmluYWwgdHJpdmVkaQ==?=> wrote in message news:5dd4940b-4135-4c8b-be87-a62a7decf5f6...

    myitem = ol.CreateItemFromTemplate("D:\my.oft", Type.Missing)

     here i m getting error : 

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).


    Ken Slovak MVP - Outlook
    Thursday, October 13, 2011 2:40 PM
  • here i m attaching whole code. pls check it. 

     

    Dim myapp As Application

            Dim myitem As MailItem

            Dim mypages As Pages

     

            myapp = CreateObject("Outlook.Application")

            myitem = myapp.CreateItemFromTemplate("D:\my.oft")

            myitem.Display()

            mypages = myitem.GetInspector.ModifiedFormPages("P.2")

            mypages.Controls("TextBox2").value = 234

    last 2 lines giving me error. 

    i want to access controls of .oft file to display data.& i m using vb.net .

    Monday, October 17, 2011 6:32 AM
  • Aside from the code in the last 2 lines, you need to do what I told you to do. You need to cast your item that you create with CreateItemFromTemplate(), which returns an Object, to a MailItem.
     
    Aside from that, did you modify "P.2" at all? Is it still called "P.2"? Is there a control on "P.2" named "TextBox2"? If so you need to set its value to a string, not to a number.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "binal trivedi" <=?utf-8?B?YmluYWwgdHJpdmVkaQ==?=> wrote in message news:940f4f1e-9e91-4c6e-b963-eeffb8a6f9db...

    here i m attaching whole code. pls check it. 

     

    Dim myapp As Application

            Dim myitem As MailItem

            Dim mypages As Pages

     

            myapp = CreateObject("Outlook.Application")

            myitem = myapp.CreateItemFromTemplate("D:\my.oft")

            myitem.Display()

            mypages = myitem.GetInspector.ModifiedFormPages("P.2")

            mypages.Controls("TextBox2").value = 234

    last 2 lines giving me error. 

    i want to access controls of .oft file to display data.& i m using vb.net .


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Wednesday, October 26, 2011 1:17 PM
    Monday, October 17, 2011 2:07 PM