VSTO & Appointments - struggling with reading/searching Appointmen

I

isuck@coding

Hi there,

I am trying to search through the appointments in my Calendar (using VSTO;
VB.NET) to identify appointments that match in Subject and Location.

I looked at the code examples on http://support.microsoft.com/?kbid=313800
and I tried both the for-loop and the for-each approach. I substituted
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

for Dim objContacts As Outlook.MAPIFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)

but then I did not get access to the .FullName method, and none of the
available methods have anything to do with retrieving Subjectname or Location
from the Appointment object.

Can someone please point me into the right direction?

Many thanks
 
K

Ken Slovak - [MVP - Outlook]

You tried this code?

Sub Main()
Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application
Dim objNS As Outlook._NameSpace = objOutlook.Session
Dim objContacts As Outlook.MAPIFolder = _
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
Dim objItems As Outlook._Items = objContacts.Items
Dim iCount As Int16 = objItems.Count
Dim i As Int16
For i = 1 To iCount
If TypeOf (objItems.Item(i)) Is Outlook.ContactItem Then
Console.WriteLine(objItems.Item(i).Fullname)
End If
Next
End Sub

Did you get any exceptions?

For VSTO, which is an addin solution, you don't create a new session. You
use the Application object passed to you by VSTO
(ThisAddin.Application.Application). Then you should instantiate your
NameSpace object by using Outlook.GetNameSpace("MAPI").

From there you should get each contact item and be able to retrieve FullName
from each contact, as well as Subject (although subject doesn't mean that
much for contacts).

By the way, this group is not for VSTO questions, it's for programming
Outlook custom forms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top