Error with Outlook.dll

Discussion in 'Questions (Windows Mobile)' started by conf, Sep 12, 2007.

  1. conf

    conf Member

    When I run app with Outlook.dll I got error:

    "An error occurred on sub app_start.

    Line number: 5

    Error description:
    TargetInvocationException"

    And I need a sample code to access Contacts in device, anybody help me?

    Thank you.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Do you run it on the device?
    Outlook library is only supported on WM5.0 and WM6.0 devices.
    If it is a WM5.0 device you should install .Net CF 2.0 and follow these instructions:
    www.basic4ppc.com/netcf2.html
     
  3. conf

    conf Member

    Yes, I run on device and my PPC use WM6.0
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the code that gives you the error message?

    Here is a code to show all the contacts (from the library manual):
    Don't forget to add the two objects and create a form with a ListBox.
    Code:
    [LEFT][FONT=Courier New][COLOR=#008000]'Contact is a Contact object and ContactsCollection is a PimCollection  object.[/COLOR][/FONT]
    [
    FONT=Courier New][COLOR=#0000ff]Sub[/COLOR][/FONT][FONT=Courier New] Globals[/FONT]

    [
    FONT=Courier New][COLOR=#0000ff]End Sub[/COLOR][/FONT]

    [
    FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][FONT=Courier New]App_Start[/FONT]
    [
    FONT=Courier New]      Form1.Show[/FONT]
    [
    FONT=Courier New]      Contact.New1[/FONT]
    [
    FONT=Courier New]      ContactsCollection.New1("Contacts")[/FONT]
    [
    FONT=Courier New]      ContactsCollection.SortItems("FirstName",false) [/FONT][FONT=Courier New][COLOR=#008000]'sorts the  contacts using the first name field.[/COLOR][/FONT]
    [
    FONT=Courier New][COLOR=#0000ff]For [/COLOR][/FONT][FONT=Courier New]i = 0 [/FONT][FONT=Courier New][COLOR=#0000ff]to [/COLOR][/FONT][FONT=Courier New]ContactsCollection.Count - 1[/FONT]
    [
    FONT=Courier New]            Contact.Value = ContactsCollection.GetItem(i)[/FONT]
    [
    FONT=Courier New]            ListBox1.Add(Contact.FirstName & " " & Contact.LastName) [/FONT][FONT=Courier New][COLOR=#008000]'Add the contact's first and last name to ListBox1.[/COLOR][/FONT]
    [
    FONT=Courier New][COLOR=#0000ff]Next[/COLOR][/FONT][/LEFT]
    [
    FONT=Courier New][COLOR=#0000ff]End Sub
    [/COLOR][/
    FONT]
     
  5. conf

    conf Member

    Thank you, Erel

    I run your code and got an errror:

    "Line 11

    Error description:
    Syntax error."

    What's wrong?
     
Loading...