• Reading item attachments programmatically (SPFile.OpenBinary Exception)

    This is a small issue that I faced the other day and wasted several hours of my time. The scenario is rather simple. You have a list item and you already have an attachment to this item. What you want to do is to read this item attachment in a workflow or a web part using code.

    So you start off by writing the following code:

    SPFile spFile = Item.Web.GetFile(Item.Attachments.UrlPrefix + Item.Attachments[0]);

    byte[] binFile = spFile.OpenBinary();

    Simple right? well you will eventually get an SPException in the OpenBinary function call and it will report that it cannot open the file!!!

    So after several hours (and several cups of coffee) I was able to perform the needed functionality but by accessing the SPFile object using the folder collection and not the URL. This is how.

    SPFolder folder = Item.Web.Folders["Lists"].SubFolders[Item.List.Title].SubFolders["Attachments"].SubFolders[Item.ID.ToString()];

    SPFile spFile = folder.Files[Item.Attachments[0]];

    byte[] binFile = spFile.OpenBinary();

    BTW this happened on SharePoint 2010 and as far as I remember the old code used to work with no problems on SharePoint 2007.

  • Lync Server 2010, Best Practices Analyzer Available for Download

    End of last week, Microsoft released Lync Server 2010 Best Practices Analyzer and now it is available for download from this URL http://www.microsoft.com/downloads/en/details.aspx?FamilyID=030548df-0dc7-4f86-b8a9-2f5ec8de8ba5&displaylang=en and the tool documentation in this URL http://technet.microsoft.com/en-us/library/gg558584.aspx.

    You can use Microsoft Lync Server 2010, Best Practices Analyzer to identify and resolve problems with your Lync Server deployment. The Lync Server 2010, Best Practices Analyzer gathers configuration information from Lync Server 2010 components.
    With the proper network access, the Best Practices Analyzer can examine servers running Active Directory Domain Services, Exchange Server Unified Messaging (UM), and Lync Server. You can use Best Practices Analyzer to do the following:

    • Proactively perform checks, verifying that the configuration is set according to recommended best practices.
    • Automatically detect required updates to Lync Server 2010.
    • Generate a list of issues, such as suboptimal configuration settings, unsupported options, missing updates, or practices that we do not recommend.
    • Help you troubleshoot and fix specific problems.


    Best Practices Analyzer provides the following features:

    • Minimal installation prerequisites.
    • Online documentation about reported issues, including troubleshooting tips.
    • Configuration information that you can save for later review.
    • State-of-the-art system analysis.

     

    Related Posts:

  • Tips & Tricks: SQL Server Mail Configuration

    After configuring SQL Server database mail and testing it successfully, you could find maintenance plans unable to send e-mails although you have set the recipients correctly.

    This is generally due to the setting for the default profile for database mail.

    Generally, you need to do the following to configure database mail:

    1.       In SQL Server Management Studio, select Management, Database Mail

    2.       Select Configure Database Mail

    3.       On the Database Mail Configuration Wizard, select setup Database Mail and configure the SMTP settings

    Secondly, you need to configure the default profile as follows:

    1.       In SQL Server Management Studio, select Management, Database Mail

    2.       Select Configure Database Mail

    3.       On the Database Mail Configuration Wizard, select Manage Profile Security

    4.       Under Public Profiles,  select Yes in the Default Profile to set the default Profile

  • WAIK SP1 Released!!

    The Windows® Automated Installation Kit for Windows® 7 SP1 has been released.

    To download the update: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=696dd665-9f76-4177-a811-39c26d3b3b34

    For the online readme help: http://technet.microsoft.com/en-us/library/dd349350(WS.10).aspx

    For a quick Q&A, check Michael Niehaus blog here: http://blogs.technet.com/b/mniehaus/archive/2011/02/17/windows-aik-for-windows-7-sp1-released.aspx

  • Windows 2008 R2 and Windows 7 SP1 RTM released

    Service pack 1 for Windows 2008 R2 and Windows 7 is now RTM and released to MSDN and technet subscribers. The service pack will be available for public download on 22nd of Feb. This release adds new features for Windows 2008 R2. Major features are for Hyper-V and they are...

    • Remote FX (details here)
    • Dynamic Memory (details here)

    For developers, one major issue that this Service Pack fixes is the crash of Windows 2008 R2 on some laptops when virtualization is enabled and Hyper-V service is installed. This is due to some issues with some graphics cards and drivers.

    Visit the technet Homepage for windows 2008 R2 SP1 and Windows 2008 R2 team blog here.