Configuring Outlook 2010 on BPOS to work with multiple exchange accounts

Instructions are modified from http://blog.migrationwiz.com/2009/06/manually-configure-outlook-for-exchange.html

I’ve been looking around all over for a way to configure multiple exchange accounts to work with Outlook 2010. The official word is that “Outlook 2010″ isn’t supported by BPOS yet, and it’s left at that. One of the fortunate things about working for a company like InterKnowlogy is that we often have the liberty to experiment with and use non-standard or un-supported technology on a regular basis. Here’s the exact steps to setup Outlook 2010 on Windows 7.

Note that you will no longer be using the BPOS client to start outlook, and these instructions are for Outlook 2010 on Windows 7 only.

Server Information (Do this for each BPOS email account)

  1. Login to Outlook Web Access.
  2. Click on Options in the top right hand corner.
  3. Click on About in the navigation bar on the left.
  4. Find the entry for Mailbox server name and write it down or record it as you will be using it later.
  5. Log out of Outlook Web Access.

Create an Outlook Profile

  1. Make sure you have Outlook 2010 installed.
  2. Open the Control Panel.
  3. Click User Accounts
  4. Click Mail.
  5. In the window that pops up, click Show Profiles.
  6. Click Add.
  7. Enter a new name for the profile. i.e. Your email address
  8. Click OK.
  9. Click Manually configure server settings or additional server types.
  10. Click Next.
  11. Select Microsoft Exchange.
  12. Click Next.
  13. Enter the mailbox server name (that you wrote down or copied from the previous section) in the field Microsoft Exchange server.
  14. Enter your full name in the field User Name.
  15. Click More Settings.
  16. If you are prompted with an error that the action cannot be completed, click OK.
  17. Click Cancel.
  18. Click on the Connection tab.
  19. Select Connect to Microsoft Exchange using HTTP.
  20. Click Exchange Proxy Settings.
  21. Enter the mobile device URL for your region.
  22. Make sure the On fast networks, connect using HTTP first, then connect using TCP/IP is checked.
  23. Click OK.
  24. Click OK.
  25. Click Check Name.
  26. Enter your User Name and Password.
  27. Click OK.
    1. IF THERE IS AN ERROR:
    2. Click More Settings.
    3. Click the Security tab.
    4. Make sure Always prompt for logon credentials is checked.
  28. Your profile should now have resolved and the correct Microsoft Exchange server should be displayed.
  29. Click Next.
  30. Click Finish.

Add an Account to Your Outlook Profile

  1. If the mail dialog is not open, repeat steps 2-5 under Create an Outlook Profile
  2. Select the profile that you want to add an account too.
  3. Click Properties.
  4. Click E-mail Accounts.
  5. Under the E-mail tab, click New.
  6. Repeat steps 9-30 under Create an Outlook Profile.
  7. Repeat steps 5-6 for each e-mail account you want to add.
  8. Open Outlook 2010.
  9. Enter credentials for each account and check the remember option(make sure that the Username and password are correct for the account it is asking you for. THEY ARE DIFFERENT)
  10. Once Outlook is started…
  11. Click File in the top left corner.
  12. Click Account Settings.
  13. Click Account Settings in the dropdown.
  14. For each account under e-mail:
    1. Select the Account.
    2. Click Change.
    3. Click More Settings…
    4. Click the Security tab.
    5. Un-check Always prompt for logon credentials.
    6. Click Ok.
    7. Click Next
    8. Click Finish
  15. Click Close

Known Issues

  • If you are NOT using the BPOS client anymore you may not get notifications to change your password.
  • Calendars will show up with an error of “No Connection” you will have to send a sharing request to see their calendar.

Native Glass Windows with WPF in Windows 7 / Vista

One of the awesome benefits of working at InterKnowlogy is that we get time to do what we call RECESS: Research and Experimental Coding to Enhance Software Skills. It’s a 4 hour time span where we can work on interesting technologies to enhance, grow, and keep up on the latest technologies and methodologies. It keeps us sharp, interested, and many of our demos have come from these short code jams.

Over the past few weeks I’ve wanted to figure out how to add or extend glass into my application like you see in Word (2010 preview):

Glass

As you can see, the whole title bar area is seamlessly integrated into the look and feel of windows, it feels native, its got that cool semi-transparent blur-the-background effect and everything. So come RECESS I did some research and pieced together what you’d need to get an effect like this.

DesktopWindowManagerAPI.cs
 
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using Codelogic.Windows.Native.APIManagedExceptions;
 
namespace Codelogic.Windows.Native
{
    public static class DesktopWindowManagerAPI
    {
        public static void AllGlassWindow(this Window window)
        {
            ExtendFrameIntoClientArea(window, new Thickness(-1), false);
        }
 
        public static void ExtendFrameIntoClientArea(Window window, Thickness thickness)
        {
            ExtendFrameIntoClientArea(window, thickness, false);
        }
 
        public static void ExtendFrameIntoClientArea(Window window, Thickness thickness, bool exceptionOnFail)
        {
            var compEnabled = IsCompositionEnabled();
            if (exceptionOnFail && !compEnabled)
                throw new DWMNotEnabledException();
 
            if (exceptionOnFail && !window.IsInitialized)
                throw new WindowNotLoadedException();
 
            if (!compEnabled) return;
 
            var margins = thickness.ToDWMMargins();
            var windowPointer = new WindowInteropHelper(window).Handle;
 
            //convert the background to nondrawing
            var mainWindowHwnd = HwndSource.FromHwnd(windowPointer);
            if (mainWindowHwnd != null)
                mainWindowHwnd.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
 
            try
            {
                DwmExtendFrameIntoClientArea(windowPointer, ref margins);
            }
            catch (DllNotFoundException)
            {
                window.Background = Brushes.White;
            }
        }
 
        public static bool IsCompositionEnabled()
        {
            try
            {
                return DwmIsCompositionEnabled();
            }
            catch (DllNotFoundException)
            {
                return false;
            }
        }
 
        #region WPF to Native
 
        private static DWMMargins ToDWMMargins(this Thickness t)
        {
            var rtrn = new DWMMargins();
 
            rtrn.Top = (int)t.Top;
            rtrn.Bottom = (int)t.Bottom;
            rtrn.Left = (int)t.Left;
            rtrn.Right = (int)t.Right;
 
            return rtrn;
        }
 
        #endregion
 
        #region Native Interop
 
        [StructLayout(LayoutKind.Sequential)]
        private struct DWMMargins
        {
            public int Left;
            public int Right;
            public int Top;
            public int Bottom;
        }
 
        /// <summary>
        /// Extends an hwind's frame into the client area by the specified margins.
        /// </summary>
        /// <param name="hwnd">Integer pointer to the window to change the glass area on.</param>
        /// <param name="margins">Margins, what to set each side to</param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        private static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref DWMMargins margins);
 
        /// <summary>
        /// Checks to see if the Desktop window manager is enabled.
        /// </summary>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        private static extern bool DwmIsCompositionEnabled();
 
        #endregion
    }
}
 

Alright, lets begin breaking this down.

DesktopWindowManagerAPI.cs
 
        [StructLayout(LayoutKind.Sequential)]
        private struct DWMMargins
        {
            public int Left;
            public int Right;
            public int Top;
            public int Bottom;
        }
 
        [DllImport("dwmapi.dll", PreserveSig = false)]
        private static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref DWMMargins margins);
 
        [DllImport("dwmapi.dll", PreserveSig = false)]
        private static extern bool DwmIsCompositionEnabled();
 

First, Windows 7 and Vista provide us with the Desktop Window Manager which was first included in Vista and continues on into Windows 7, it manages all the cool graphical windowing and effects you see in those operating systems. It also gives us an API dll to access these all the features, including many that are unavailable in WPF.

The first declaration you see sets up the data type that the DLL uses internally to represent Left, Right, Top, and Bottom glass margins. The others are pointers to unmanaged (non .NET) methods in the DLL. DwmExtendFrameIntoClientArea is the method that allows me to adjust how far in the glass extends in to the client drawable area, and DwmIsCompositionEnabled tells me if Aero Glass is enabled.

DesktopWindowManagerAPI.cs
 
        private static DWMMargins ToDWMMargins(this Thickness t)
        {
            var rtrn = new DWMMargins();
 
            rtrn.Top = (int)t.Top;
            rtrn.Bottom = (int)t.Bottom;
            rtrn.Left = (int)t.Left;
            rtrn.Right = (int)t.Right;
 
            return rtrn;
        }
 

A simple extension method (denoted by the ‘this’ in front of the Thickness t, it allows me to write the declaration as though the method were part of the Thickness class, so if I have a thickness variable thick I could convert it to a DWMMargins type by writing var margins = thick.ToDWMMargins();) it converts a WPF Thickness object to the internal DWMMargins struct.

DesktopWindowManagerAPI.cs
 
        public static void ExtendFrameIntoClientArea(this Window window, Thickness thickness)
        {
            ExtendFrameIntoClientArea(window, thickness, false);
        }
 
        public static void ExtendFrameIntoClientArea(this Window window, Thickness thickness, bool exceptionOnFail)
        {
            var compEnabled = IsCompositionEnabled();
            if (exceptionOnFail && !compEnabled)
                throw new DWMNotEnabledException();
 
            if (exceptionOnFail && !window.IsInitialized)
                throw new WindowNotLoadedException();
 
            if (!compEnabled) return;
 
            var margins = thickness.ToDWMMargins();
            var windowPointer = new WindowInteropHelper(window).Handle;
 
            //convert the background to nondrawing
            var mainWindowHwnd = HwndSource.FromHwnd(windowPointer);
            if (mainWindowHwnd != null)
                mainWindowHwnd.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
 
            try
            {
                DwmExtendFrameIntoClientArea(windowPointer, ref margins);
            }
            catch (DllNotFoundException)
            {
                window.Background = Brushes.White;
            }
        }
 
        public static bool IsCompositionEnabled()
        {
            try
            {
                return DwmIsCompositionEnabled();
            }
            catch (DllNotFoundException)
            {
                return false;
            }
        }
 

Finally I wrapped native methods with .NET versions that take a more useful WPF Window class and WPF Thickness class for the ExtendFrameIntoClientArea method. Internally it checks to make sure the window is initialized and that Desktop Composition is enabled, gets the integer pointer to the window, resets the background, and then calls the native method to extend the glass into the drawable (client) area of the window. Two custom classes not shown are the DWMNotEnabledException class and the WindowNotLoadedException class, which are thrown if something goes wrong.

That’s all well and good, but wouldn’t it be nice if we didn’t have to worry about all these calls to this custom DesktopWindowManagerAPI class and could just set how much we wanted the glass to extend into the client area? Or bind it to something so that the glass area expands or contracts when a value changes?

I thought so:

GlassWindow.cs
 
using System.Windows;
using Codelogic.Windows.Native;
 
namespace Codelogic.Controls.WPF
{
    public class GlassWindow : Window
    {
         #region Glass Thickness Dependency Property
 
        public static readonly DependencyProperty GlassThicknessProperty = DependencyProperty.Register(
            "GlassThickness", typeof(Thickness), typeof(GlassWindow), new PropertyMetadata(new Thickness(0, 0, 0, 0), GlassThicknessChanged));
 
        //when the thickness changes, apply the change to the window.
        private static void GlassThicknessChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((GlassWindow)d).UpdateGlassState();
 
        }
 
        /// <summary>
        /// Local property for Glass thickness.
        /// </summary>
        public Thickness GlassThickness
        {
            get { return (Thickness)GetValue(GlassThicknessProperty); }
            set { SetValue(GlassThicknessProperty, value); }
        }
 
        public static readonly DependencyProperty IsAllGlassProperty = DependencyProperty.Register("IsAllGlass",
                                                                                                   typeof(bool),
                                                                                                   typeof(GlassWindow),
                                                                                                   new PropertyMetadata(
                                                                                                       OnIsAllGlassChanged));
 
        private static void OnIsAllGlassChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((GlassWindow)d).UpdateGlassState();
        }
 
        public bool IsAllGlass
        {
            get { return (bool)GetValue(IsAllGlassProperty); }
            set { SetValue(IsAllGlassProperty, value); }
        }
 
        private void UpdateGlassState()
        {
            if (!IsInitialized) return;
 
            if (IsAllGlass)
                this.AllGlassWindow();
            else
                this.ExtendFrameIntoClientArea(GlassThickness);
        }
 
        static GlassWindow()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(GlassWindow), new FrameworkPropertyMetadata(typeof(GlassWindow)));
        }
 
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            UpdateGlassState();
        }
    }
}
 

Alright, this class creates a WPF Window subclass, adds a dependency property for GlassThickness and a change handler that internally calls the DesktopWindowManagerAPI.ExtendFrameIntoClientArea if the window is loaded or attaches an event handler if the window is not loaded. Now all you have to do is change your window class over to a GlassWindow class, set the thickness and you rock and roll!

GlassDemoWindow.cs
 
<WPF:GlassWindow x:Class="Codelogic.Controls.WPF.Demo.GlassDemoWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WPF="clr-namespace:Codelogic.Controls.WPF;assembly=Codelogic.Controls.WPF"
    Title="Glass Window Demo" 
    Height="300" 
    Width="300"
    GlassThickness="10000">
    <Grid>
        <InkCanvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent" />   
    </Grid>
</WPF:GlassWindow>
 

Glass Ink

Something I have not yet done that I would like to do is figure out how to add functional buttons into the title-bar of an application. If you remember the Microsoft Word snippet from above there’s save / undo / redo buttons in the title bar. But that will have to be a later post.

Hope someone enjoyed my Glassy exploration,

Updates:

  • 2 Dec 2009
    • Changed ExtendFrameIntoClientArea to check to see if window.IsInitialized instead of window.IsLoaded
    • Updated GlassWindow to override OnSourceInitialized instead of adding an event handler for Loaded
    • Added in a method that turns the entire client area into glass by setting the margins to -1.
    • Changed Glass Window to have a Boolean Dependency property to turn it all glass.

- Paul Rohde

WCF Manual Service Hosing on Windows Vista and Windows 7

With the new security features introduced in Windows Vista and now in Windows 7 there are some, not so obvious, problems that have crept in and cause weird errors in even simple code. I was building a simple web service for the first time a simple HelloWorld in a console application to make it easy to debug and output trace information. Nothing complicated, a little different because I was configuring everything manually in code as opposed to using configuration file. Here’s the code for my simple, stripped down HelloWorld service:

ConsoleServer.cs
 
using System;
using System.ServiceModel;
 
namespace ConsoleServer
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Server...");
 
            ServiceHost serviceHost = new ServiceHost(typeof(HelloWorldService),
                new Uri("http://localhost:9000/TestService"));
 
            serviceHost.AddServiceEndpoint(
                typeof(IHelloWorldService),
                new WSHttpBinding(),
                "");
 
            serviceHost.Open();
 
            Console.WriteLine("Started");
 
            Console.ReadLine();
        }
    }
 
    //operation contract
    [ServiceContract]
    public interface IHelloWorldService
    {
        [OperationContract]
        string HelloWorld();
    }
 
    public class HelloWorldService : IHelloWorldService
    {
        public void HelloWorld()
        {
            System.Threading.Thread.Sleep(1000); //sleep for one second
            return "Hello World Service";
        }
    }
}
 

And the client:

ConsoleClient.cs
 
using System;
using System.ServiceModel;
using ConsoleServer;
 
namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Client");
 
            ChannelFactory<IHelloWorldService> myChannelFactory =
            new ChannelFactory<IHelloWorldService>(
                        new WSHttpBinding(),
                        new EndpointAddress
                            ("http://localhost:9000/TestService"));
            IHelloWorldService wcfClient = myChannelFactory.CreateChannel();
 
 
            System.Threading.Thread.Sleep(3000);
            Console.WriteLine("Calling Hello World");
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(wcfClient.HelloWorld());
                Console.WriteLine("- Called HelloWorld");
            }
 
            Console.WriteLine("Done");
 
            Console.ReadLine();
 
 
        }
    }
}
 

The code is fairly straight forward as far as services go, running it however I began getting the following error:

HTTP could not register URL http://localhost:9000/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Extremely unhelpful, and the link provided by Microsoft offers no solutions (insert eye roll here) so I went off to consult Google… After a bit of research I discovered that it was the security features in Window 7 and Windows Vista that had been causing the problem, mostly because I’m trying to do everything manually in code some of the permission requests or other behind the scenes magic that normally occurs when Visual Studio 2008 creates and hosts a service from an application configuration file don’t happen. (My guess is that when visual studio installs it sets up permissions for Cassini, it’s inbuilt web server, and that when you run your service the ‘normal’ way that it automatically wraps your service in Cassini, effectively bypassing the normal application security measures, but that’s another story). Long and the short of it is that if you want to do this yourself you need to add some permissions to your user (by default even administrator accounts in Windows 7 and I *think* Windows Vista run in a restricted mode) to allow you to register your service with windows. (The original article is here)

Run a Command Prompt with Administrator privileges (Actually right click and select it), type and run the following command (replace the port number with whatever port you are using, 9000 for the code above, and your domain(or computername if your not on a domain) and username).

netsh http add urlacl url=http://+:8000/ user=DOMAIN\UserName

And *BAM* everything magically works. Cool huh?

- Paul Rohde

An Afternoon Installing Windows 7

menuii

widgetsiiWith Microsoft releasing the beta of their new Windows 7 I decided to go ahead, install in see how well it works and runs in school / development as a primary operating system. I’m currently on a Lenovo Z61p laptop that’s provided by our school with the following specs:

  • T7600(2.33GHz)
  • 2GB RAM
  • 100GB 7200rpm HD
  • 15.4in 1920×1200 LCD
  • 256MB ATI FireGL V5200
  • CDRW/DVDRW
  • 802.11n wireless
  • Bluetooth
  • Modem
  • 1Gb Ethernet

Installation took about an hour and 30 minutes off of a burned dvd (x64 bit edition), about 2 restarts and about 5 minutes at the end to setup, provide user name and password, timezone, and so on. I was a bit worried that I would have issues connecting on the wireless but the drivers that came with Windows 7 were able to find all the networks right off the bat. That being said, there seems to be a slight issue when the wireless requires you to accept a security certificate, it continues popping up multiple times before it finally lets you enter your domain username and password (since my computer is not registered on the Neumont domain). Fortunately after just letting it pop up enough times it eventually let me enter my credentials and connected without a problem.

Next step was installing drivers. Lenovo offers a system update utility that runs, checks your system, shows what drivers and updates are available and will download and install the ones you select. Installed the updater, selected all the critical updates and some of the recommended updates, hit go, and it ran and installed everything without a hitch. The most notable update was for my graphics driver which allowed the Areo glass effect, oddly, it didn’t automagicly switch from the flat basic window manager to Areo, I had to go in and switch manually, but after that everything seemed to work fine, I haven’t had any BSOD (Blue Screens of Death) yet after about 4 hours of running it.

As was getting ready to start installing the software I use, I began having some issues installing Alcohol 52% (For those of you who don’t know, Alcohol 52% allows you to create a virtual cd/dvd drive and access .iso and other files as CD’s or DVD’s), after doing a bit of research it seems that Alcohol and Daemon tools both have some issues with Windows 7 and the way they install and register the virtual drive. Currently I’m playing with Virtual Clone drive which seems to working well so far, I did get a BSOD when I tried to restart my computer, but it has worked fine after that. Other than that virtual clone drive has been working fine mounting and demounting all the iso’s I have of my software. Most everything has installed correctly, including SQL server 2008, Visual Studio 2008, Netbeans, Glassfish v2, Java EE, Expression Studio, Microsoft Office, Digsby and so on.

Windows 7 has a large number of interface improvements, seems to be a bit faster and runs with a smaller memory footprint than vista, and is most of all backward compatible with previous vista drivers which is one of the big reasons I believe that it will surpass vista in popularity. I for one am really looking forward to the final release near the end of this year.

- Paul Rohde