Lake District Holiday

My wife and I have just returned from a week's holiday in the Lake District. We stayed at a place called Pullwood Bay, which is situated just outside Ambleside on the shores of Lake Windermere. Pullwood Bay is the former residence of Victorian industrialist Sir William Crossley and was also used as a school in later years. There are a total of 13 self-catering apartments, all finished to a very high standard.

I highly recommend it as a holiday destination.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Useful Outlook Macro

If, like me, you use the RSS feeds feature in Microsoft Outlook 2007 to download podcasts, then you probably find that your .pst file grows very big, very quickly. I wrote a short macro to automatically save all the attachments from an RSS feed to a specified folder.

Open the Visual Basic Editor in Outlook (Alt+F11), create a new module and insert the following code snippet:

Private Const path As String = "[path to folder]"
Private Const feedName As String = ".NET Rocks!"

Private Sub SaveAttachments()

    Dim ns As Outlook.Namespace
    Dim feeds As Folder
    Dim feed As Folder
    
    On Error Resume Next
    
    Set ns = Application.GetNamespace("MAPI")
    
    Set feeds = ns.GetDefaultFolder(olFolderRssFeeds)
    Set feed = feeds.Folders(feedName)

    Dim item As PostItem
    
    For Each item In feed.Items
    
        If (item.Attachments.Count > 0) Then
        
            Dim att As Attachment
            
            For Each att In item.Attachments
            
                Dim fileName As String
                fileName = path & att.fileName
                att.SaveAsFile fileName

            Next
            
            Dim i As Integer
            Dim attCount As Integer
            
            attCount = item.Attachments.Count

            item.Display
            
            For i = attCount To 1 Step -1
                item.Attachments(i).Delete
            Next

            item.Close(olSave)

        End If
        
    Next

End Sub

One thing that is a little frustrating is that in order to remove the attachments from each RSS item, you have to open each item, remove each attachment and then save the item. When running the macro, this can cause a bit of flickering, which is a minor annoyance but a small price to pay for the time it saves.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Simplifying SharePoint Development

I think SharePoint is a fantastic product, but developing with SharePoint can be a very frustrating experience.

Today, I was writing an Event Receiver so that when an item in a particular list was added or updated, it would send an email to the person who created the item and to the list administrator.

The first version of my event receiver assembly didn't generate any emails, so I needed to debug it in real time to find out where it was going wrong. This is what I had to do:

  1. Install Visual Studio 2005 on the SharePoint server.
  2. Copy the Visual Studio project from my PC onto the server.
  3. Build the project and install the assembly into the Global Assembly Cache (GAC).
  4. Register the event receiver with the list using a small console application.
  5. Perform an IIS reset, or recycle the application pool for the SharePoint web application.
  6. On the Visual Studio Debug menu, choose "Attach to Process..." and attach the debugger to all of the ASP.Net worker processes (w3wp.exe) running on the server.
  7. Set a breakpoint in the code.
  8. Open the SharePoint site in a browser, navigate to the list and add an item.
  9. Step into Visual Studio and step through the code line by line to identify the error(s).
  10. Stop debugging, edit the code and correct the error(s).
  11. Repeat from step 3.

After a while, this became really tiresome and repetitive and this got me wondering if there was a way to simplify the process.

It occurred to me that I could have used a Visual Studio post-build event to automatically install the assembly into the GAC and do an IIS reset for me. If you type "SharePoint post-build events" into your favourite search engine, you'll find lots of resources describing how to do this.

Unfortunately, by the time I realised this, my event receiver was almost finished and I decided it wasn't worth the extra effort for this particular project. But I'll certainly do this on my next project and I would urge all SharePoint developers to do the same!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5