Andrew Coates ::: MSFT

It's all about community!

November, 2007

  • Andrew Coates ::: MSFT

    What, more fishbowl movies?

    • 1 Comments

    The last batch of Virtual TechEd Fishbowl movies from TechEd Australia have been posted. Check 'em out! (You'll need to page down at least once because VTE's been to South Africa, Japan, and now Barcelona in the mean time)

    Click to Play

    A Veteran WIT Tells her Story

    In this last WIT installment from Tech·Ed Australia, Rose Watson, Microsoft Technical Account Manager, relays to Charlene Clark how she has successfully worked in the IT field for more than 18 years while at the same time raising a family. She emphasizes the importance of taking the necessary time to achieve a satisfying work-life balance.

    Watch Now

    Click to Play

    Another Successful Woman in Technology

    Hear another successful woman working in the IT field tell her story about how she started her career, and how she encourages women to “go for it” when considering this industry, with Kathy Kam, Microsoft Program Manager, and Charlene Clark, from Queensland Rail.

    Watch Now

    Click to Play

    What’s Expression?

    Shane Morris, Microsoft User Experience Evangelist, and Ron Jacobs, host of ARCast.TV, carry on a lively chat about Expression. What’s Expression? Simply put, the technology is about providing tools for designers—user interface designers, interaction designers, graphic designers, and others—so they get a seat at the table when technology is developed.

    Watch Now

    Click to Play

    A Community Leader in Security

    Orin Thomas, Security MVP, is widely involved in a number of Security-related endeavors. Listen in as he speaks with Michael Kleef, Technology Advisor, about www.windowsitpro.com (where he is associate editor), his involvement with the Melbourne Security and Infrastructure Interchange, and his two Tech·Ed Australia sessions “Pushing the limits of EFS in Windows Vista and Windows Server 2008” and “Deploying and managing a Microsoft Windows Server Update Services 3.0 Server.”

    Watch Now

    Click to Play

    WIT Series Video

    Join Zaakera Stratman, Program Manager for Virtual Tech·Ed, as she interviews Bronwen Zande, Windows Live Services Development Specialist, about Bronwen’s first exposure to computers and her organic entry into the IT field—helping her Dad write a program for his work when she was in high school! Bronwen and Zak share what they love about being women in the technology industry and how to overcome stereotypes women face.

    Watch Now

    Click to Play

    The SQL Server Community

    In this video recorded at Tech·Ed Australia, Catherine Eibner, Cybner Computer Solutions, and Peter Ward, Chief Technical Architect from Wardy IT and recently-awarded MVP, talk about Peter’s session “Things You Need to Know for a Painless Upgrade to Microsoft SQL Server 2005” and his involvement in the Sequel Server Community.

    Watch Now

    Click to Play

    Windows Server 2008 Scenarios

    Werner Kasselman and Amit Pawar, Microsoft Technical Specialists, describe Windows Server 2008 scenarios, and in particular they cover the branch office scenario. With Windows Server 2008, customers can manage their branch, reduce their costs and gain all the services they need in an optimized environment.

    Watch Now

    Click to Play

    Women in Technology

    In this WIT video recorded at Tech·Ed Australia, Nikki Curtis from the Australian Computer Society and Charlene Clark, Queensland Rail, talk about how they got started in IT, some of the challenges women face when growing their IT careers, and tips for young women considering entering the field.

    Watch Now

  • Andrew Coates ::: MSFT

    Illusions - How can this be true?

    • 4 Comments

    Michael's twirling dancer link generated a lot of chatter, but this one seems even less fathomable to me

    Michele's posted an image as an example of your brain messing with your head (as it were). In this image, the squares marked A and B are the same colour!

    Don't believe me? I didn't either, so I snipped a small part of the image and placed it in Paint.

    image

    Still didn't look possible, so I drew a rectangle next to the image, split it in 2 and used the eye dropper tool to pick up the colour first from square A (and filled the left segment) and then from B (and filled the right segment).

    image

    As my son would say - "Freaky!"

  • Andrew Coates ::: MSFT

    Searching for Contacts in VSTO

    • 0 Comments

    I LOVE VSTO v3!

    As part of my demos for Graham Seach's Office DevCon, I've developed a VSTO v3 Outlook Add-in that adds a form region to an incoming e-mail if:

    1. The sender is in my contacts (based on the e-mail address); and
    2. The contact has a non-null, not-empty company name

    Here's what I did to start off with:

    // look up the contact from the sender of the mail
    Outlook.MailItem thisMail = (Outlook.MailItem)e.OutlookItem;
    Outlook.MAPIFolder ContactFolder =
       (Outlook.MAPIFolder)thisMail.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
    foreach (Outlook.ContactItem contact in ContactFolder.Items)
       {
       
          Outlook.ContactItem contact = (Outlook.ContactItem)obj;
    
          if ((contact.Email1Address == thisMail.SenderEmailAddress ||
             contact.Email2Address == thisMail.SenderEmailAddress ||
             contact.Email3Address == thisMail.SenderEmailAddress) &&
             !(contact.CompanyName.Trim() == ""))
          {
             // Instantiate the service and get the details of the company's sales
             SalesDetails.svcSalesDetails.SalesDetailsServiceClient svc =
                new SalesDetails.svcSalesDetails.SalesDetailsServiceClient();
    
             _salesDetails = svc.GetSalesDetails(contact.CompanyName);
             found = true;
             break;
          }
       }

    This threw an InvalidCastException in the foreach line complaining that the object (of type System.__comobject) couldn't be cast to a ContactItem.

    So next I looped through the items in the folder as a collection of objects and did the cast within the loop. 

    foreach (System.Object obj in ContactFolder.Items)
    {
    Outlook.ContactItem contact = (Outlook.ContactItem)obj;
    
    

    Same issue (at the cast line again). I'm not sure why I thought this would work any better.

    I got a little sidetracked by the first paragraph of Sue Mosher's response to this question on OutlookCode.com and added

    Marshal.ReleaseComObject(contact);

    at the bottom of the loop (especially as by this stage I'd discovered that it wasn't the first object in the collection that was throwing the exception - it was about the 270th - near enough to Sue's 250).

    Actually, I was running into the issue addressed in her second paragraph, but I didn't read that. It took me a call to Nick Randolph (just before we went off to play hockey) to realise that a contact folder can contain things other than Contacts. Thanks Nick.

    An easy way to filter the collection is to use the Restrict() method:

    Outlook.Items colItems = ContactFolder.Items.Restrict("[MessageClass]='IPM.Contact'");

    Finally things were working, but they were still SLOW. Turns out it's lots quicker to let the built-in search function do the heavy lifting; in particular the Find() method. The final incarnation of my find code now looks like this:

    Outlook.ContactItem contact;
    if (e.OutlookItem is Outlook.MailItem)
    {
       // look up the contact from the sender of the mail
       Outlook.MailItem thisMail = (Outlook.MailItem)e.OutlookItem;
       Outlook.MAPIFolder ContactFolder =
          (Outlook.MAPIFolder)thisMail.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
    
       Outlook.Items colItems = ContactFolder.Items.Restrict("[MessageClass]='IPM.Contact'");
       string FilterString = "[Email1Address] = '" + thisMail.SenderEmailAddress + "' OR " +
          "[Email2Address] = '" + thisMail.SenderEmailAddress + "' OR " +
          "[Email3Address] = '" + thisMail.SenderEmailAddress + "'";
       contact = (Outlook.ContactItem)colItems.Find(FilterString);
    }
    else
    { ...

    The moral of the story is two-fold:

    1. Check your types before attempting to cast; and
    2. The built-in methods for searching or filtering are almost always better than those you try to roll yourself (it's all about the platform, man!)
Page 2 of 2 (13 items) 12