code and politics don't mix

March 18, 2003 under Computers, Politics, Programming

Winds of change. Times, they are a changin’. Yada yada. Did a good DoD wipe of the ol’ hard drives recently and switched things up a bit. Normally, I keep shortcuts of my most often used apps on the desktop and in the quick launch area I keep IE, OE, Windows Explorer and “Show Desktop”. I’ve done this since Windows 95. Out with the old and in with the nucleus. Takin’ a cue from old skool MacOS, here are my new desktops; home and work.

Here’s something that came up at work. If you need to save off a shitload of attachments from emails in a given folder of Microsoft Outlook (not Outlook Express), you can use this Visual Basic macro that I wrote (and thoroughly commented) in under 10 minutes:

Option Explicit
 
' Contants
Public Const LOCAL_FOLDER As String = "C:\My Attachments\"
 
' Purpose: Save off attachments in an Outlook/Exchange folder
'          to an already-existing local folder.
Sub save_attachments_locally()
   Dim objOutlook, objNameSpace, objMailItem, objAttachment, _
          objFolder As Object
   Dim nI, nJ As Integer
   Dim strLocalFolder As String
 
   ' init Outlook objects
   Set objOutlook = Application
   Set objNameSpace = objOutlook.GetNamespace("MAPI")
   Set objFolder = objOutlook.ActiveExplorer.CurrentFolder
 
   ' loop through all of the objects in the selected folder
   For nI = 1 To objFolder.Items.Count
      ' grab the current item in the loop
      Set objMailItem = objFolder.Items.Item(nI)
      ' loop through all of the attachments of the current item
      For nJ = 1 To objMailItem.Attachments.Count
         ' grab each mail attachment
         Set objAttachment = objMailItem.Attachments
         ' save each mail attachment to the local folder
         objAttachment.Item(nJ).SaveAsFile _
            LOCAL_FOLDER & objAttachment.Item(nJ).DisplayName
      Next nJ
   Next nI
 
   ' all done ;)
   MsgBox "Files have been saved locally in: " & LOCAL_FOLDER
End Sub

I’d add more to it, like the ability to choose the destination folder, remove the saved attachments from their repsective email, etc… but I didn’t have time. Hey, it’s open source. You can add to it! 😀

So it looks like there’ll be a war. Like I’ve told Pat before, I don’t offer opinions on this. I’m just a guy that makes a living developing software and web sites. I’ve never ran a country before. I’ve never had a job in world politics, or any level of politics for that matter. War or peace? I dunno. My opinion on this won’t hold much water. To paraphrase the late Phil Hartman (who tought us that charming Canadian men should not wed psychotic American women) as his character in the Frozen Caveman Lawyer skits from SNL

“I’m just a simple software developer. Your world politics and foreign policies frighten and confuse me.”

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>