Saving All Attachments in Outlook

Back on January 3’rd, 2007 (http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/ or http://shrinkster.com/mhm) I posted a useful macro that would save attachments on the selected items in a folder. Since then several have written asking for a version that would save all attachments for every item in a folder, whether it was selected or not.

UPDATE: Some users were having problems downloading the code, so I’ve posted it at: http://arcanecode.com/2011/07/16/revisting-the-outlook-save-all-attachments-macro/

I finally had a chance to experiment, and it turned out to be very easy. To create a version that saves attachments for all items, you only have to change three lines of code.

The first line is the name of the sub. I changed

Public Sub SaveAttachments()

To

Public Sub SaveAllAttachments()

Easy enough. Next, the variable declaration of

Dim Sel As Outlook.Selection

Has to be changed to

Dim Sel As Outlook.Items

The final change is to

Set Sel = Exp.Selection

It becomes

Set Sel = Exp.CurrentFolder.Items

And that’s it, it works. Let me explain what’s happening. In the original, I was cycling through the Selection collection of the Outlook Explorer object. The Selection is a special type of Items collection that holds what’s selected.

For our new macro we wanted all of the items in the current folder, not just what was selected. The first thing we had to do, after changing the sub’s name, was to change the data type of the Sel variable. I wanted to get away from the specific selection collection to the more generic items collection.

Then, all I had to do was have the Sel point to the Items collection of the current folder. Since both Selection and CurrentFolder.Items both support the Items interface, everything else just worked. That’s the power of OOP!

I’ve uploaded a new version of the file as Save All Attachments. It contains this version, the original SaveAttachements, and the GetOutputDirectory function. If you are installing this new, please don’t forget to set a reference to the Microsoft Scripting Runtime Library (scrrun.dll).

Select Tool, References from the VB Macros Editor. Scroll down until you find Microsoft Scripting Runtime, and check it. You’ll know it’s the right one when the file name is scrrun.dll.

[VB References Dialog]

I’ve tested this with messages stored in a variety of folders, including the Inbox. It’s based off the current folder, so it doesn’t seem to care where you are at. I’ve also gotten this to work with the calendar as well.

There you go, you now have a choice. Using my original macro you can save attachments for only the selected items in the current folder, or using this version you can save all attachments for all items in the current folder. I hope the folks who requested the change will find this fits their needs, enjoy!

 

What to do with Ubuntu

OK, you’ve now installed Ubuntu under Virtual PC or on your spare machine, or perhaps as your main computer. If you are a “newbie” to Ubuntu, as am I, you might want some suggestions on things you can do with your spiffy new OS. Never fear, I have scoured the web and found some sites and other blogs with some good suggestions.

Linux on Desktop: 13 Things to do immediately after installing Ubuntu.

http://linuxondesktop.blogspot.com/2007/02/13-things-to-do-immediately-after.html or http://shrinkster.com/mgd

Has some really useful suggestions on some basic things you will want to do to make you Ubuntu experience more enjoyable.

Ten Tips for New Ubuntu Users

http://www.linux.com/article.pl?sid=06/06/08/1651225

Just as it says, some useful tips for those new to Ubuntu.

Check out the Ubuntu Forums

http://www.ubuntuforums.org/

Lots of good info and a good community to ask questions and learn more.

LinuxReality

http://www.linuxreality.com/

A great podcast on Linux. Chess Griffin does a really good job with lots of info, including (search the archives) a three part introduction to Ubuntu.

Mono

http://www.mono-project.com/Main_Page

If you are here, most likely you have some interest in .Net development. Mono is the open source project to allow you to do .Net development on the Linux platform. Check out the Mono pages for more info on .Net programming in Ubuntu.

Installing Ubuntu 6.10 on Virtual PC 2007 Step by Step

Update April 24, 2008 – The newest version of Ubuntu, 8.04 is out. Look for complete install instructions here.

Update: October 18, 2007 – Ubuntu 7.10 is now out, for full instructions on installing it, see
http://arcanecode.wordpress.com/2007/10/18/installing-ubuntu-710-under-virtual-pc-2007/


Note: If you are looking for instructions for version 6.06, see my post at: http://arcanecode.wordpress.com/2006/12/19/installing-ubuntu-on-virtualpc-step-by-step/. There are still good reasons to install 6.06, mostly because it’s the version targeted as the LS, or Longterm Support version. Many companies will likely stick with 6.06 for some time. For the past few weeks I’ve been trying to install Ubuntu 6.10 under VPC 2007, using the standard install model. I’ve come to an important conclusion. It can’t be done. (If you’ve figured out how, leave a comment cluing the rest of us in on it!)

Now, before you become distraught and start with the wailing and gnashing of teeth, note I said “standard install model”. There is a way to get it working.

Before you get started, spend a few minutes getting familiar with VirtualPC if you have not already done so. You can find my step by step instructions for VirtualPC at http://arcanecode.wordpress.com/2006/09/20/virtual-pc-step-by-step/. Keep it handy, at various points I will be referring to it. OK, let’s get started.

First, you need the right installer. Go to the Ubuntu website (http://www.ubuntu.com). Under desktop, click the Download link. Scroll down to the Ubuntu 6.10 area. Click on the region you live in, and find a mirror close to your location. Now, here is the inside trick, instead of “CD Image for desktop and laptop PC’s”, you should instead select “Other installation options”.

When the next screen comes up, scroll down to the “Alternate install CD” area. Find the link that says “PC (Intel x86) alternate install CD” and download the ISO it’s associated with. It’s a big download, so be patient.

[Ubuntu 6.10 Step by Step]

UPDATE! UPDATE! Ubuntu has changed their site, and so far I haven’t been able to find the alternate cd via their site. For now you can go to http://mirrors.gigenet.com/ubuntu/6.10 and grab the file ubuntu-6.10-alternate-i386.iso. This is the same file I was describing. We now return you to your regularly scheduled blog post…

Note that selecting the right version is the first thing you have to know, but there’s a few other tweaks you’ll have to do during the install process, so keep reading.

Once you have it downloaded, burn it to a CD or use Virtual CDRom Control Panel (see my post http://arcanecode.wordpress.com/2006/09/13/virtualization/) to load it into a drive.


In Step 1 of my VirtualPC Step by Step you are instructed to create a new machine, please do so. I’ve named mine “Ubuntu 6.10”. In step 2, you are prompted for your OS. You will need to pick Other. In step 3, you are asked about Ram. Ubuntu will run OK under 256 megs, however if you have the available space I’d highly suggest upping it to 512, especially if you intend to get into doing some graphics or mono coding. I’ve selected 512 meg for this tutorial.In step 4 you will want to create a new hard disk, and in step 5 confirm what you’ve selected. OK, now you are up to step 6, installing the OS, which is where this tutorial picks up.Your first screen comes up, but before you start pressing buttons there’s one tweak you have to make. So you can see everything correctly during the install, press the F4 (VGA) button. Select a video mode that ends with 16, in my example you can see I changed to 800 x 600 x 16.
[Ubuntu 6.10 Step by Step]
Now you can proceed, press enter to start the “Install in text mode” option.


The first screen to come up asks about your language. I took the default of English, but if you are elsewhere please select your language, then press Enter to continue.
[Ubuntu 6.10 Step by Step]


Next you are asked for your location. Select your location, or the one closest to you, and press Enter.
[Ubuntu 6.10 Step by Step]


Next you are asked to let the installer determine your keyboard. Take the default, Yes, which will take you to the next screen.[Ubuntu 6.10 Step by Step]


You will then be asked to press a series of keys. Here’s the first screen in the series:
[Ubuntu 6.10 Step by Step]On some screens there may be keys you don’t have, if so just wait for the time out.


After going through each screen, you will see what keyboard pattern Ubuntu detected for you. If it’s correct just click Enter to continue, if not you can go back and reselect.
[Ubuntu 6.10 Step by Step]


Next Ubuntu will scan for your CD rom, then begin loading components. Just kick back and wait, it will go through all sorts of detection steps as it finds hardware, networking, and more.
[Ubuntu 6.10 Step by Step]


If all went well, you will now be asked for a host name. I took the default of Ubuntu, but you are free to change it. Enter your host name, or just hit Enter to continue.
[Ubuntu 6.10 Step by Step]


Next Ubuntu will begin detecting your disks and hardware. Be patient. You will then be asked about partitioning disks. This should be a new partition, so take the default by pressing Enter to continue.
[Ubuntu 6.10 Step by Step]


The next screen is the first place you don’t want to take the default. It’s asking you to confirm the partition format plan. Use your left arrow to move the red bar (shown below on No) over to the Yes side, then you can press enter.
[Ubuntu 6.10 Step by Step]
Wait while Ubuntu formats your drives.


Next you are asked for your time zone. Select it, then press Enter.
[Ubuntu 6.10 Step by Step]


Next you are asked if the system clock is set to UTC. I just took the default of Yes, this is easy enough to fix if it’s wrong.[Ubuntu 6.10 Step by Step]


Next you are asked for your name. Note this is not your login user name, but your real name. Ubuntu will use this in your documents and e-mails. I entered a name, and pressed enter to continue.
[Ubuntu 6.10 Step by Step]


On the next screen you are prompted for the user name you want. This is what you will enter when you login. Enter something that suits you, then press enter to continue.
[Ubuntu 6.10 Step by Step]


If you’ve done this sort of thing before, you’d probably guess Ubuntu wants your password next, and you’d be right. Enter a password and press enter to continue.
[Ubuntu 6.10 Step by Step]


Now you are asked to re-enter the password, to confirm. Do so and press enter to go on.
[Ubuntu 6.10 Step by Step]


Now sit back and wait. Ubuntu will start installing itself.
[Ubuntu 6.10 Step by Step]


After running for a while, you are next asked about video modes. Use the space bar to toggle the modes you want, and use the arrows to move up and down. When you’ve selected the modes you want, press enter to continue. Below you can see I’ve selected a few common modes for my system.[Ubuntu 6.10 Step by Step]


OK, sit back and wait some more, while Ubuntu installs various software packages. This step takes a loooooooooong time.[Ubuntu 6.10 Step by Step]


Ubuntu has completed it’s install. But don’t hit enter quite yet! First, on the Virtual PC menu pick CD, Release Physical Drive Z: (where z is the drive you are installing Ubuntu from). This will let Ubuntu to boot from your newly installed virtual hard drive instead of the CD. After you’ve released the drive, you can hit Enter to continue.
[Ubuntu 6.10 Step by Step]
When the system reboots, you will see your login screen, but it’s going to look very trashy. Don’t worry, we’ll fix in a moment.


Key in your user name, and press Enter. You probably won’t be able to read what you are typing so be careful.[Ubuntu 6.10 Step by Step]


If all went well, you’ll now see another garbled screen where you enter your password. Carefully, do so and press enter.[Ubuntu 6.10 Step by Step]


More garbled screens will appear. When it appears as if Ubuntu has loaded (see below, if you look close you can make out the menu across the top), press the CTRL+ALT+F1 key combo.
[Ubuntu 6.10 Step by Step]


This key combo exists the graphic interface and puts Ubuntu in text mode. Key in your user ID, then (when prompted) password to login.[Ubuntu 6.10 Step by Step]


You’ll now see a command line, below.
[Ubuntu 6.10 Step by Step]We need to modify your xorg.conf file to change the color depth. First, let’s back it up. Type in this command:sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backupNote to copy it exactly, Linux is case sensitive, so if you were to type in say x11 instead of X11 your command will fail. Also, because you are attempting to run the command as the root user (the sudo part of the command) you will be prompted for your password.


Now that we’ve backed it up, we need to edit it. Type in this command:sudo nano /etc/X11/xorg.confYour new screen should look like this:[Ubuntu 6.10 Step by Step]


Press CTRL+W (Where is) and when prompted key in DefaultDepth and press enter.You should now be landed on DefaultDepth. Cursor over to the 24…
[Ubuntu 6.10 Step by Step]


And hit delete twice, then type in 16.
[Ubuntu 6.10 Step by Step]Now hit CTRL+O (WriteOut) to save the file, and press enter to take the default xorg.conf file name. Then hit CTRL+X to exit.


You’re now back at the command prompt. Just type in this command:sudo reboot
and press enter.
[Ubuntu 6.10 Step by Step]


Give it several minutes to shut down and restart. If everything worked, you should now see a beautiful, non garbled Ubuntu screen.[Ubuntu 6.10 Step by Step]


Key in your user name and password and you will be logged in to your working copy of Ubuntu 6.10 on Virtual PC 2007![Ubuntu 6.10 Step by Step]

Virtual PC 2007 Released

Not sure when they slipped this in, but Microsoft has now release Virtual PC 2007. Like it’s predecessor, 2004, it’s still free.

Learn more at http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx or http://shrinkster.com/me8

or go directly to the download at

http://www.microsoft.com/downloads/details.aspx?FamilyId=04D26402-3199-48A3-AFA2-2DC0B40A73B6&displaylang=en

or http://shrinkster.com/me7
I’ll keep you updated as to my experiences, please feel free to leave a comment with yours…

Arcane Review: Why Software Sucks

I promised myself I wasn’t going to have a blog filled with a lot of book reviews. But having just finished “Why Software Sucks” by David S. Platt (http://www.amazon.com/Why-Software-Sucks-What-About/dp/0321466756/sr=8-1/qid=1172286512/ref=pd_bbs_sr_1/105-8037691-1992410?ie=UTF8&s=books or http://shrinkster.com/mdg), I find I can’t resist mentioning it.

David S. Platt is a software developer, author, and teacher at Harvard University Extension. However this book is not targeted at the experienced software developer, but instead at the average computer user. He gives the reader a basic knowledge of how software works, so they will know what is possible and what is not. Armed with knowledge about the possibilities of software development, the average joe can then determine when software sucks as opposed to just bumping into current limitations.

One reviewer on Amazon said he “…didn’t find anything new in the book for seasoned UI developers.” That’s a shame, as it shows he clearly didn’t get the point of the book. This book is not targeted at developers. It’s for users, so they will know when you’ve written good software, and when you’re handing them crap.

While it’s true this book is not packed with development techniques, it’s still an important read for any programmer. As a developer with over twenty years experience, what Mr. Platt’s book gave me was insight. To be reminded that the code I write is to be used by people other than developers. He helped me to see my application through the eyes of an average user, or to quote Mr. Platt, “Your users are not you!”

This was not a thick or expensive book, and was filled with enough humor to keep it a quick yet enjoyable read. At the same time it was serious enough to deal with the subject of user interfaces in a meaningful way. After reading this book, I think the best compliment someone will be able to give me about my applications is “it just works!”

For more information see the authors site at http://whysoftwaresucks.com/.

Standard disclaimer, I make no money from book sales, nor have I any financial affiliation with Amazon, the author, David S. Platt, the publisher, the guys who grew the trees that got turned into paper the book was printed on, the truck drivers that delivered the books, the company that hosts the authors website, nor am I the father of Anna Nicole Smith’s baby. Just so that’s all clear.

 

[Why Software Sucks Book Cover]

SSIS, BIDS, and TNSNAMES

Today’s alphabet soup has to deal with an issue we struggled over this week at work. For those unfamiliar, SSIS is SQL Server 2005 Integration Services. It’s the rewrite of SQL Server 2000 DTS (Data Transformation Services). You use SSIS to pull data from one database and put it into another.

You develop SSIS in BIDS, Business Intelligence Developers Studio. BIDS is Visual Studio with the BI tools added in. The issue we’ve been fighting had to do with getting our SSIS packages to use Oracle 10g drivers to talk to the Oracle 9i data source that was the beginning point for our packages.

Over and over we got an error that the OLEDB provider could not “Acquire” the database, yet the data source kept passing the “Test Connection” test. It was one of my associates who came upon the clue.

In our environment, we don’t normally use a TNSNAMES.ORA file. TNSNAMES is where Oracle normally stores information about a schema name. Schema names are kind of like URLs. You use a human readable schema name, something like WAREHOUSE1. Oracle driver then goes into TNSNAMES to find the server information so it knows where to route the data to.

As I said, in our environment we don’t use TNSNAMES, instead we have another file. The data driver looks there to get the server that TNS info is stored at for the whole company. This allows us to have a single place to store (and update) TNS data instead of thousands of workstations.

The problem was, BIDS didn’t like that. Even though we had it redirected, BIDS didn’t recognize that and kept going to the TNSNAMES file to find schema info, and in our case it couldn’t find it because it wasn’t there. Once we added a TNSNAMES file BIDS was able to acquire it’s schema info, connect to the database and get whatever data it needed.

The moral of the story is, if you are having problems in BIDS connecting to an Oracle data source verify that you do indeed have a valid TNSNAMES.ORA file.

Collections in C# – The Stack

Yesterday we looked at the Queue class. The queue is used when you need a first in, first out (FIFO) way to read through your collection. Sometimes though you need to read so that the first item you retrieve is the most recently added item, much like the computer’s stack, or a Pez candy dispenser (http://www.pez.com).

With the stack class, the most recently added item is the first one you pull out. Stacks have a count property and peek method, much like it’s cousin the queue. However, the stack uses push and pop to get items on and off the stack. Let’s take a look.  

      Stack myStack = new Stack();

      myStack.Push(“1. Carl Franklin”);

      myStack.Push(“2. Richard Campbell”);

      myStack.Push(“3. Mark Miller”);

      myStack.Push(“4. Kimberly Tripp”);

      myStack.Push(“5. Billy Hollis”);

 

      while (myStack.Count > 0)

      {

        Console.WriteLine(myStack.Pop());

      }

      Console.ReadLine();

 

[Picture of Stack Output Example 1]

 

As you can see, the pop operation removed the items from the collection in the reverse order from which they were loaded. In other words, the last item on is the first one you’ll be pulling off.

The peek method works just like it does with the queue. Modifying the while loop above thusly:  

      while (myStack.Count > 0)

      {

        Console.WriteLine(“Peek: “ + myStack.Peek());

        Console.WriteLine(“Pop : “ + myStack.Pop());

      }

 

Produces this output:

 

[Picture of Stack Output Example 1]

 

Stacks are handy when you want to keep track of objects that need to be handled in the reverse order, say for creating and disposing. Like queues, stacks enforce reading your data in a specific order. Whenever you have a requirement to read in a LIFO order, the stack class will add the extra safety you need to make your applications work as you designed.

Follow

Get every new post delivered to your Inbox.

Join 106 other followers