Finding DASL Property Names

The LINQ-to-DASL provider of the Office Interop API Extensions provides a very limited set of mappings between its query types and their associated DASL properties.  We didn’t have the time to add them all and we didn’t know which properties (besides the obvious ones like Subject and DateReceived) users would be most likely to use…

0

Debugging LINQ-to-DASL Queries

When your LINQ-to-DASL queries do not return the results you expect, how do you determine where the problem is?  The issue could be that the query simply doesn’t do what you expect.  For example, you could be querying the wrong DASL properties and therefore Outlook returns no (or unexpected) items.  (This is easy to do,…

3

Filter Outlook Items by Date with LINQ to DASL

I received an email over the weekend asking why the following LINQ to DASL query threw an exception: Outlook.Folder folder = (Outlook.Folder)Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); var appointments = from item in folder.Items.AsQueryable<Appointment>() where item.Categories.Contains(“Personal Appointments”) && item.Item.Start.Date >= DateTime.Now – new TimeSpan(30, 0, 0, 0) select item.Item; foreach (var appointment in appointments) { MessageBox.Show(appointment.Start.ToString()); } The query looks…

8

LINQ to DASL Walkthrough

Now that the Office Interop API Extensions have been released, I thought I would post a complete walkthrough of a simple LINQ to DASL application. Let’s start with my fictitious Outlook calendar: This calendar shows that I have four appointments today. The appointments have been categorized as either “Work” (blue) or “Personal” (green). Suppose I…

0

Parameterized Properties and the Office Interop API Extensions

One of the disadvantages of C# compared with VB is its lack of support for parameterized properties. Instead, parameterized properties in C# are exposed as normal method calls prefixed with “get_” and “set_”. This is particularly apparent when working with the Office object model as it exposes many such properties, the majority being indexers on…

0

Office Interop API Extensions Now Available!

As announced in Andrew Whitechapel’s post, version 1.0 of the VSTO Power Tools have been released!  One of those tools is the Office Interop API Extensions, a set of libraries which extend the Office object model to simplify development on the Office platform.  This past week I’ve blogged about the capabilities of these extensions and…

13

Extending LINQ to DASL with Custom DASL Properties

In an earlier post I discussed LINQ to DASL, part of the Office Interop API Extensions, which is one of the forthcoming VSTO Power Tools.  LINQ to DASL allows you to write LINQ expressions against Outlook item collections.  I also mentioned that many known DASL properties were not mapped to their Outlook item equivalents in…

4

Using LINQ with the Office Object Model

In my last post I talked about LINQ to DASL, a LINQ provider that converts query expressions into their DASL equivalent in order to efficiently filter item collections in Outlook.  But LINQ to DASL solves only a very specific problem for one particular application.  The Office object model has many types of collections that we might like…

1

Query your Outlook Inbox with LINQ to DASL

Quick, tell me what the following code does: Outlook.Folder folder = (Outlook.Folder) this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); string subject = “VSTO”; string filter = @”@SQL=(“”urn:schemas:httpmail:subject”” LIKE ‘%” + subject.Replace(“‘”, “””) + @”%’ AND “”urn:schemas:httpmail:date”” <= ‘” + (DateTime.Now – new TimeSpan(7, 0, 0, 0)).ToString(“g”) + @”‘)”; Outlook.Items restrictedItems = folder.Items.Restrict(filter); foreach (Outlook.MailItem item in restrictedItems) { System.Diagnostics.Debug.WriteLine(String.Format(“Body: {0}”, item.Body));…

14

Banish Missing.Value with the Office Interop API Extensions

I like VSTO.  I like C#.  What I don’t like is having to write VSTO code in C# like: object fileName = “Test.docx”; object missing  = System.Reflection.Missing.Value;   doc.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); This code creates a copy of…

1