November 2004 - Posts

Google Scholar

Google does it again.

Google Scholar enables you to search specifically for scholarly literature, including peer-reviewed papers, theses, books, preprints, abstracts and technical reports from all broad areas of research.

I'm currently working on my Thesis and I think this will come in handy for all my reference lookups. I have used it for a few today and it has led me exactly where I needed to go.

Thanks Google.

Posted by puzzlehacker | with no comments

Outlook macro to permanently delete items in junk email folder

If you are anything like me you hate using the mouse to right click on your Outlook Junk E-mail Folder to select Empty "Junk E-mail" Folder and then on top of that you have to click Yes when it asks you "Are you sure you want to permanently delete all the items and subfolder in the "Junk E-mail" folder?". I hate doing that and I'm more of a hotkey kind of person so I wanted some way to do this with a hotkey.

A while ago I remember KC Lemson posted a macro to delete the items in your Junk E-mail folder, which works great except that it just puts the items from the Junk E-mail folder into the Deleted Items folder where as I wanted to permanently delete them. I modified her macro so that it permanently deletes the items from the Junk E-mail folder (well sort of).

In the Outlook Object Model there is no direct way to permanently delete an item, so I found this post which suggested we just delete the item twice, once from the original folder and once from the Deleted Items folder, which seems to be a pretty simple work around. Anyway here is the macro code:

Public Sub EmptyJunkEmailFolder()

    Dim outApp As Outlook.Application
    Dim junkFolder As Outlook.MAPIFolder
    Dim junkItem, deleteItem As Object
    Dim entryID As String
    
    Set outApp = CreateObject("outlook.application")
    Set junkFolder = outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderJunk)
    
    For Each junkItem In junkFolder.Items
        entryID = junkItem.entryID  ' Store item entry id
        junkItem.Delete             ' Delete from junk mail folder
               
        ' To permanently delete item find and delete from deleted items
        Set deleteItem = outApp.Session.GetItemFromID(entryID)
        deleteItem.Delete
    Next
    
    Set junkItem = Nothing
    Set deleteItem = Nothing
    Set junkFolder = Nothing
    Set outApp = Nothing
    
End Sub

Once you setup this macro you can add a toolbar button and set the accelator key to something unique and then you have a hotkey to permanently delete the items from your Junk E-mail folder. If you need help doing any of those things take a look at KC's macro post which has some good information and links on how to do those things.

Also incase anyone is in search for the Outlook or Office Object Model Documentation here is a link that tells you how to find it (it took me longer than I care to say to find this ;).

UPDATE: This msdn article talks you through how to create a personal ditigal signature so Outlook doesn't complain every time you run the macro.

 

The Spec# programming language

I'm working on my MS Thesis project (I hope to post more on this soon) and I came across Spec# which is a new programming language that is being worked on by Microsoft Research.

Spec# is a superset of C# that adds things like non-null types, checked exceptions and contracts (i.e. pre and post conditions and invariants).

If you are interested in Formal Specifications or Design-by-Contract then you might want to take a look at the Spec#'s research group publications. There are very few publications right now but I suspect there are more to come.

C++ static variables

I'm working on a project in C++ and I created a static member function and a static data member in one of my classes. When I tried to compile I kept getting an unresolved external error that was pointing to my static data member and I couldn't figure out what the problem was. Finally after some research (via Google, Msdn, and Stroustrup) I figured out that you have to define the static data member outside the class declaration.

I don't consider myself to be a novice C++ programmer but I don't think I ever knew this rule. Am I the only one who didn't know this? I guess for the most part I don't use static member variables very much, I know I have used local function static variables and static functions but I guess I have never used a static data member because I know I would have remembered this rule. At any rate I know now and knowing is half the battle ;)

Here is a small code snippet to show what needs to be done:

  1 // MyClass.h
  2 class MyClass
  3 {
  4 public:
  5 	static int GetCount() { return count; }
  6 private:
  7 	static int count;
  8 };

  1 // MyClass.cpp
  2 #include "MyClass.h"
  3 int MyClass::count; // Also do any initialization if needed.
More Posts