Error with Outlook.dll

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.
 

Erel

B4X founder
Staff member
Licensed User
Longtime 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.
B4X:
[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]
 

conf

Member
Thank you, Erel

I run your code and got an errror:

"Line 11

Error description:
Syntax error."

What's wrong?
 
Top