August, 2012

  • Akash Blogging......

    Outlook displaying the Red X mark instead of the Image

    • 1 Comments

    This was a fun issue to troubleshoot! The problem : Compose a new mail in Outlook 2010, Insert a image and send it to yourself. The expected behavior is that when you open the received mail, you see the Image.

    In this case, instead of the Image we saw Red X mark with the message “The linked image cannot be displayed.  The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location.”

    image

    The interesting part was that everything worked fine in Safe mode! What could be causing this issue?
    In general, when we open an Item that has embedded images, the images are copied to a temp location which is then used for displaying the image. When the Item is closed the Images are deleted from that location. On further troubleshooting and debugging the issue, we noticed that in this case the Images never got created!

    Knowing this was a BIG help to track down this issue. The question: Where is the temp location picked up from and does it really exist? On debugging we found that Outlook was reading the value from the follow key:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cache

    The value that was read in this case was %CACHEDIR%\Cache . Is this the right value? I guess NOT. In a working case it gives us the full path to the Temporary Internet Files, something like “C:\Documents and Settings\username\Local Settings\Temporary Internet Files”
    When I looked at a few machine in my environment the values were as below:
    On a Windows XP machine: %USERPROFILE%\Local Settings\Temporary Internet Files
    On a Windows 7 machine: %USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files
     
    In this case the problem machine was a Windows XP machine, we replaced %CACHEDIR%\Cache with %USERPROFILE%\Local Settings\Temporary Internet Files and then restarted Outlook.
    Now everything WORKS?

    Why did it work in Safe mode? In Safe mode, Outlook takes a different code path and a different API to get the temp folder location and does that successfully!
    Enjoy!

  • Akash Blogging......

    Exchange 2013 Preview is now AVAILABLE!

    • 0 Comments


    Download Microsoft Exchange Server 2013 Preview
    http://technet.microsoft.com/en-US/evalcenter/hh973395

    Developer Resources for Exchange 2013

    EWS client design overview for Exchange 2013
    http://msdn.microsoft.com/en-us/library/jj190904(EXCHG.150).aspx

    Exchange Web Services Managed API Version 2.0 - Technical Preview
    http://www.microsoft.com/en-us/download/details.aspx?id=30391

    New features in EWS in Exchange 2013
    http://msdn.microsoft.com/en-us/library/jj190903(EXCHG.150).aspx

    New features in the EWS Managed API
    http://msdn.microsoft.com/en-us/library/jj220500(EXCHG.80).aspx

    Exchange 2013 101 Code Samples
    http://code.msdn.microsoft.com/Exchange-2013-101-Code-3c38582c

    Get started with mail apps for Outlook 2013 and EWS in Exchange 2013
    http://msdn.microsoft.com/en-us/library/jj190901(EXCHG.150).aspx

    Enjoy!

  • Akash Blogging......

    Using–Filter, Select-Object, ForEach-Object in C# – Exchange PowerShell Automation

    • 0 Comments

    Have you ever tried migrating Exchange PowerShell script to be used from C# code?  I needed to convert the following script to C#

    Get-Mailbox -filter {ResourceType -ne "Room"}| Select-object Alias,DistinguishedName,Identity | foreach-object {Get-MailboxFolderStatistics $_.Alias}

    If you run the above script in Exchange 2010 Management Shell you might get the following error message:

    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
    PSInvalidOperationException
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

      This error is caused because the Windows PowerShell remoting feature doesn't support more than one pipeline running at the same time. To resolve this issue, store the output of the cmdlet earlier in the pipeline in a variable, and then pipe the data stored in the variable to the ForEach cmdlet as shown below:

    $Mailboxes = Get-Mailbox -filter {ResourceType -ne "Room"}| Select-object Alias,DistinguishedName, Identity 
    $Mailboxes | foreach-object {Get-MailboxFolderStatistics $_.Identity}

    Now, to get the code working in C#. How do I use the Filter ? How do I use the Select-Object ? How do I store the intermediate result and then pass it into the ForEach-Object? The below code snippet shows how this can be done. I you need a full example of using Exchange PowerShell from C#, you can find it here .

    //TODO: Create and Open Runspace, Create and Import Session
    //Create a pipline
    Pipeline pipe = runspace.CreatePipeline();

    //Add the first command Get-Mailbox with the filters
    Command CommandGetMailbox = new Command("Get-Mailbox");
    CommandGetMailbox.Parameters.Add("Filter", "ResourceType -ne \"Room\"");
    pipe.Commands.Add(CommandGetMailbox);

    // Do a Select-Object on the fields
    var props = new string[] { "Alias", "DistinguishedName", "Identity"};
    Command CommandSelect = new Command("Select-Object");
    CommandSelect.Parameters.Add("Property", props);
    pipe.Commands.Add(CommandSelect);

    //Invoke the First Pipeline and get the results
    resultMailboxes = pipe.Invoke();

    // Create a second Pipeline..
    Pipeline pipe2 = runspace.CreatePipeline();

    // Do a write-output of the results so that it can be piped to the foreach
    Command Command1 = new Command("write-output");
    Command1.Parameters.Add("InputObject", resultMailboxes);
    pipe2.Commands.Add(Command1);

    //Pipe into the ForEach
    Command CommandForEach = new Command("ForEach-Object");
    CommandForEach.Parameters.Add("Process", ScriptBlock.Create("Get-MailboxFolderStatistics -Identity $_.Identity"));
    pipe2.Commands.Add(CommandForEach);

    //Invoke the second Pipeline..
    resultMailboxes = pipe2.Invoke();
    //TODO: Display the results and clean up


    Enjoy!




Page 1 of 1 (3 items)