?
=?ISO-8859-1?Q?Kurt_H=E4usler?=
Hi. I am trying to get Outlook.Items SetColumns method to work, and have
found a relevant knowledge base article Q184462.
I cant cast it to a Outlook.ContactItem (like I would do if I didnt use
the SetColumns) and if I leave it as Object, it contains no FullName and
gives a compile error.
Here is the relevant VB code:
Sub SetColumns_Example()
Dim ol As Outlook.Application
Dim MyFolder As MAPIFolder
Dim itms As Items
Dim itm As Object
Dim dtmStart As Date, dtmEnd As Date
Dim lngElapsed As Long
Set ol = New Outlook.Application
Set MyFolder = ol.Session.GetDefaultFolder(10)
Set itms = MyFolder.Items
itms.SetColumns "[FullName],[CompanyName]"
Debug.Print "WITH SETCOLUMNS"
Debug.Print Time
Debug.Print "------------------"
dtmStart = Time
For Each itm In itms
Debug.Print itm.FullName & ", " & itm.CompanyName
Next
Why doesnt VB give a compile error, class Object does not contain FullName?
Here is my c# code so far:
---
Outlook.Items contactItems = contactsFolder.Items;
contactItems.SetColumns("FullName");
Outlook.ContactItem contact = (Outlook.ContactItem) contactItems.Item
(counter);
string fn = contact.FullName;
----
Without the SetColumns, the cast works. Doing it like the VB snippet,
i.e. contact as an object, I get the compile time error, object does not
contain FullName.
Any hints on how to get this to work in c#?
Thanks a lot.
found a relevant knowledge base article Q184462.
I cant cast it to a Outlook.ContactItem (like I would do if I didnt use
the SetColumns) and if I leave it as Object, it contains no FullName and
gives a compile error.
Here is the relevant VB code:
Sub SetColumns_Example()
Dim ol As Outlook.Application
Dim MyFolder As MAPIFolder
Dim itms As Items
Dim itm As Object
Dim dtmStart As Date, dtmEnd As Date
Dim lngElapsed As Long
Set ol = New Outlook.Application
Set MyFolder = ol.Session.GetDefaultFolder(10)
Set itms = MyFolder.Items
itms.SetColumns "[FullName],[CompanyName]"
Debug.Print "WITH SETCOLUMNS"
Debug.Print Time
Debug.Print "------------------"
dtmStart = Time
For Each itm In itms
Debug.Print itm.FullName & ", " & itm.CompanyName
Next
Why doesnt VB give a compile error, class Object does not contain FullName?
Here is my c# code so far:
---
Outlook.Items contactItems = contactsFolder.Items;
contactItems.SetColumns("FullName");
Outlook.ContactItem contact = (Outlook.ContactItem) contactItems.Item
(counter);
string fn = contact.FullName;
----
Without the SetColumns, the cast works. Doing it like the VB snippet,
i.e. contact as an object, I get the compile time error, object does not
contain FullName.
Any hints on how to get this to work in c#?
Thanks a lot.