Monthly Archives: July 2007

Outlook and Attachment Strangeness

0
Filed under Office, Troubleshooting

Dealing with attachments in Outlook is a bit like entering an Ultimate Fighting match against a professional half-octopus, half-eel. It really doesn’t matter what style of fighting you choose, the octo-eel is guaranteed to take you down more than once in the match, and there’s really no telling whether you have a chance at winning.

An app that I’m working on deals with attachments in Outlook, more specifically, it deals with Office format attachments, so we’re talking about DOC, XLS, and PPT files (and about 2 dozen other *X and *M formats introduced in Office 07).

Anything else (like BMPs, TXT files, etc) are supposed to pass on through like yesterday’s iceberg salad.

However, astute customers noticed that, in some cases, the order of the attachments could change at times. If you had numerous attachments to your email, and you intended on them being in a particular order, that might not go over well.

Now, you might think, with such a nicely laid out object model as Outlook’s, that preserving the order of attachments in a message would be trivial. Hell, you might even thing you could simply replace one attachment with another, simply by using a replace method or somesuch.

And you’d be wrong.

There’s no replace method, unlike GroupWise. And the ATTACHMENTS.ADD method doesn’t allow you to specify an ordinal. It does allow you to specify a position, but that value is only used to indicate the character position of the attachment in an RTF format email. If the email format is plain text, or HTML, the position isn’t used at all.

Then there’s this jewel from the MSDN documentation on the add method.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.

Special.

Add to all of that the fact that Word can also be used as the email editor (albeit in approximately the same capacity as the built-in Outlook RTF editor from what I can tell), and you have a whole lot of arms to fight with on this octo-eel.

The bottom line however, turns out to be relatively simple.

  1. First, you have to make a single pass through all the attachments in a message and for every one you plan on removing, you need to add the new one. In addition, for those that you don’t plan on removing, you have to extract them, then add them again anyway, in the same order as they already exist.
    This will cause the email to end up with a double set of attachments; the originals, and all the new ones, plus a second copy of any original attachments you didn’t necessarily want to mess with but have to anyway.
  2. Next, make another pass through all the attachments, removing all of the original attachments, but leaving everything else. Now, the email will contain the proper list of attachments, both new and untouched originals, in the original order, at least for plain text and HTML formats.
  3. For Rich Text, there’s one more trick….
  4. When you add the new attachments (or re-add those attachments you intend to pass through, in step 1 above), retrieve the POSITION of the attachment first.
    If it’s 0, make sure you add the new attachment WITHOUT specifying a position argument. Specifying a 0 for the position will only mess things up.
    If it’s NOT 0, however, add the new element with a position argument of the original POSITION + 1

It sounds more complicated than it is.

If you get any part of it wrong, you’ll know pretty quick. Usually, the attachments will end up in the sent email reversed in order. Worse case, some will end up missing.

One final trick. Testing all this can be a real pain, but you can make it a little easier.

Set up Outlook with POP accounts only (don’t use Exchange for this). Then set it to NOT send email on startup:

image 

Anything you send will end up in the outbox, where you can examine it, use it for debugging, drag it back to the inbox to attempt a resend, or delete it. And from what I can tell, whatever ends up in the outbox is what would go. There’s no additional processing done after that.

Plus, you don’t even have to use a legitimate TO address, anything that looks like an email address will work.

Believe it or not, I actually like Outlook, despite it’s, uh, quirks? It’s been my email system since about 97. I’ve never had a corrupted PST file, never lost an email (that I didn’t unintentionally delete with Shift-Del), and never gotten an email-born virus.

Now, excuse me, I have some serious knocking to attend to. 

Bootable USB Keys

1
Filed under Hardware, Utilities

Maybe I’m jumping on the band wagon a bit late with this one, but it’s pretty slick if your machine’s BIOS will support it.

It IS actually possible to write a boot sector and boot files to those little 256mb+ USB keys that you can get in the gumball machine down at just about any local soda fountain or 10 cent store these days.

Why would you want to?

  • They boot a LOT faster than CD or DVD
  • They’re rewritable without any special considerations.
  • You don’t have to have special burner software to update them (other than what’s required to lay down a boot sector).
  • You don’t have to suck up an EIDE channel just to be able to hook up a CD to boot to.

It was that last part that hooked me. I’m in the process of upgrading a TIVO to 320GB and my shiny new iron only has 1 EIDE port (and 2 channels). One to the old TIVO drive, one with the new drive and, bang, nothing to boot to (You don’t want to boot to Windows with your TIVO drive attached, Windows like to stamp any drives that it can see, which can screw your TIVO drive all to hell).

With a bootable USB key with MFSTools on it, I can boot to the USB, and still have both the HD’s connected to copy and back up between them.

I know, I know. Grab an old machine with 2 IDE ports and my problem was solved. Well, the only old machine I have left is way, way old, and it’s bios doesn’t even recognize the 320gb drive I’m using to upgrade. The other, not so old machine, is just waiting to be hauled to the hazardous waste site, cause it won’t even give up a POST BEEP.

To get DOS or windows on the disk, you’ll need to format the USB Key with a boot sector. The easiest way I found to do that is this HP utility. It should let you format the drive and copy the boot sector over from a boot floppy. Once that’s done, you should be able to grab a copy of BARTPE and build up a fully USB KEY bootable copy of Windows XP, assuming you have a bootable CD of Windows XP. Well, it ain’t a “full” Windows XP but it’ll get you loaded and able to grab info of an otherwise unbootable drive.

To get Linux working, you gotta go deep. You’ll have to use SYSLINUX, and/or ISOLINUX to overwrite the DOS boot sector with a LINUX boot sector.

To get MFSTools working on the resultant LINUX USB key, you’ll need to get the ISO first. Mount it using something that’ll mount ISO images, like Elaborate Byte’s free and excellent Virtual Clone Drive. Then copy the whole thing down to the USB key. This won’t copy the boot sector, though. That’s what SYSLINUX was for.

Still won’t quite work though. You have to copy the contents of the ISOLINUX folder down to the root of the USB key. Then Rename ISOLINUX.CFG to SYSLINUX.CFG. That’ll allow the ISOLINUX image to boot to a ram drive like it does normally when booted from CD (at least, that’s the way I understand it, knowing what I know about Linux at this point).

If all that’s done right, and assuming that your machine supports booting from USB, and assuming you’ve configured the BIOS to allow it, reboot and feel the joy.

If it doesn’t work, take two aspirin, reboot and… be thankful Windows doesn’t require this sort of nonsense….???? Ok. I jest.

BartPE is a very interesting possibility because it’s relatively easy to build and you can add your own Windows tools to the mix (up to the size of your USB key anyway). Could come in very handy for recovery and forensics work. And USB Keys are more scratch resistant than CD’s. Plus, some have that nifty, switchblade action with the USB plug.

image or image

Oh, and one final tidbit for any security oriented people, check this out and see if you get any sleep that night.

Disabling the UAC for Administrators Only (or rather, Not Quite)

0
Filed under Security, Vista

Ever since I disabled UAC on my Vista machine, I’d been hoping for a way to disable it only for specific users.

Then I just stumbled across a promising page for disabling the UAC prompting for administrators only.

It wasn’t the “Per User disabling of UAC” that I was hoping for, but I’d take it.

In a nutshell, run SECPOL.MSC from the Start, Run box

Expand Local Policies, and select Security Options.

Find the entry “User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode” in the list (it’s towards the end) and double-click on it.

Change the setting to “Elevate without prompting”.

Note that this won’t work with Vista Basic and Home, because those versions don’t come with the SECPOL.MSC file. Check out the blog above for a reg script for that.

So, then, I thought,  just setup an Admin user for doing standard development stuff (where the UAC is just a flat pain in the ass), then, login as a NON-ADMIN user with UAC enabled to test things out.

Well, not so fast. Turns out, even with the Automatic elevation setting on, elevation still doesn’t happen quite right in all cases. Take for instance, Winternal’s Process Explorer:

image

That Replace Task Manager option will cause a “Process Requires Elevation” prompt with UAC enabled, regardless of the “Elevate without prompting” setting mentioned above, so there’s more to this that what would appear to be mentioned in the help for that security option. Granted Process Explorer is pretty low level stuff, but it’s something I use all the time.

Screw that. Not worth bothering with, so off goes the UAC again.

Sucking up 80 Columns of Code

3
Filed under VB Feng Shui

There’s an interesting discussion on SlashDot asking the question of whether we collective programmers should drop the old “80 column” standard that’s still so prevalent and go with some larger number, say 132, or, possibly something even bigger.

With the new widescreen displays, this would almost seem to make perfect sense.

But I think I’d side with the majority of posters that 80 columns is more than enough in most situations. Besides that, there are very good reasons that newspapers and magazines don’t print articles the full width of the page, but instead create columns. The eye just has a hard time sucking up that much stuff .

In the typical programming book I have, I counted an average of about 74 chars per line (proportional, so the number could vary, though not by much). In the paper back books I checked, I see about 54 chars per line. These are single column books.

80 would seem just about right. Long enough to deal with the typical indentation of a programming language, but short enough to keep you from getting lost on the line.

Besides, other than those lines with long tables or strings of text, why would you create a very long line of code? C is pretty notorious for allowing such nonsense with it’s ? operator and inline assignments, but there’s very few that would argue those things make the code more readable. VB has it’s “:” statement separator, but there are very few instances where I’ve seen it put to particularly good use.

Convention generally holds that you want to stick to one statement per line. And typical statements should be far less than 80 chars long.

On a related note, I have a few other questions to throw out

  • How many spaces should a tab comprise?
  • Is it better to program black on white or white on black?
  • Do color coded syntax highlighting editors actually help or just distract?
  • Should web pages go columnar when the chars per line exceed some number (for instance, browsing full screen on a widescreen monitor)?

For me, it’s:

  • 3 (2 is too few to be visually distinct, and 4+ takes up too much line space),
  • White on Black (with a white background, there’s just too much light coming at me. It’s almost blinding to run an editor full screen on a 24″ widescreen with a white background.
  • Not much, although I do tend to color comments in a dimmer color than the rest of the code. Everything else I tend to leave as white text, unless it’s a very specific file format. For instance, I have coloring rules for INI files and XML files to highlight the sections, keynames, and element tags.
  • Up in the air on this one. On slashdot, maximized, I count about 230 chars per line on my widescreen monitor. They run as a single column and just stretch it out to accommodate the browser. Many news pages simply limit the max width of the page to somewhere around 1024 pixels or so. Here’s a typical MSN page maximized on my system:

image

That seems like a waste to me.

Vista’s New Recursive Folder Structure

4
Filed under Vista

How’s this for a peculiar error message:

image

This one is from FileBackPC (a normally awesome little backup app). I can configured a rule for my server (which runs FileBack) to reach out to each of my workstations and grab a backup of certain folders, including the entire user profile.

There’s the rub. Apparently, Vista creates a hardlink from the “Application Data” folder back to its parent. This results in a recursive folder structure that is guaranteed to give fits to any app that recursively traverses the dir structure.

Vista itself appears to “know” what’s up though. You get this if you try to navigate into the Application Data folder via Explorer:

image

This same technique works great with XP. In the FileBack, I just had to reconfigure the rule to not traverse into that folder. Other apps might not be so obliging.

Sigh. Yet another one of “those little issues.”

Flying Model Simulator and Vista

3
Filed under Helicopters, Troubleshooting, Vista

Apparently, DirectX supports something called “retained mode”. Not exactly sure what it is or what it does.

But I just found out that one of my favorite apps, Flying Model Simulator or FMS requires it and you get a lovely dialog that “D3DRM.DLL cannot be loaded” when you install the latest FMS 2 Alpha 85

A little digging and it seems this is quite the problem with a number of older DirectX programs. I suppose MS figured that if the app is more than a few years old, nobody would possibly want to use it anymore:-(

Anyway, this forum posting discusses the problem and pointed me to the Dell web site here to download the missing file.

Copy it to my fresh and shiny clean System32 folder and I’m flying my simulated RC heli again.

image

Here’s something interesting. If I switch windows away from FMS, it pauses in the background, which is actually quite nice.

I don’t recall it doing that under XP.

Something to actually like about Vista? I…feel….so….dirty…. 

Vista and the UAC , Or not

1
Filed under Security, Vista

Well, I finally succumbed.

After hours of working to get some scripts going that, with XP took all over about 10 minutes the first time around, I’ve given up.

I simply opened the Windows Users control panel applet and turned off UAC.

image

Lo and behold, everything works just like it did back in XP.

I know, I know. “Users won’t run with UAC turned off so how are you going to properly test your app?”

Well, how ’bout a VM with Vista in it and the UAC turned on?

Even better, my user account with UAC off, and a Test User account with minimal rights and UAC turned on. (But I haven’t yet figured out how or if  you can turn UAC on, on an account by account basis, Anyone have any ideas?)

I’m not happy about it, but I refuse to spend any more of my time clicking those damn “accept” boxes.

Not only that, but I’ve heard not just a few respected programmers in the community say things to the effect of “Vista is just too difficult to program under, I’m going back to XP.”

My question is, if running Vista without the UAC is basically like running XP, then, at least from a developer perspective, why not just run Vista without the UAC, then test on a VM with it? Does continuing on with XP bring anything to the table that Vista without UAC leaves out? From what I can tell, no.

Is it ideal? No. Is it better than XP? Well, the drivers and eye candy are nice, but otherwise, I don’t see much difference. Surely there’s additional security details that have been cooked in that have nothing to do with UAC, so I’ll get their benefits.

And when PowerToys for UAC (Ugh) comes out and I can munge the UAC as necessary to get everything I need working properly, I can turn it back on.

VB Finally Gets Real

0
Filed under VB Feng Shui

Bill McCarthy has written a very revealing “What’s Hot” for the July Visual Studio Magazine. First off, the name of the “version after the next version” of VB (VB 10) is apparently VBx. I have to believe that that’s some small homage to VB3 (for those that were around, that was the summer of ’93, I still have the 5.25″ floppies of the beta)  and the .VBX custom control that was the precursor to VB’s OLE custom controls (OCX’s) and in many ways, VB’s entire concept of classes.

I suppose if it was less than 14 years ago, there might be some confusion over the naming, but, hey, it was 14 years ago, so I’ll let that slide<g>.

One minor note here. Bill’s article indicates that VBx is the “next version of the VB compiler”, which isn’t quite true according to this posting on the VB Blog.

Bigger news is that the VB team is rolling out the Interop Forms Toolkit 2.0, which allows you to create OCX controls and integrations with VB6, in VB.NET. Now, as intriguing as this nugget is, it makes me wonder. VB6 is scheduled for End-of-Life in 2008. Introducing such a toolkit so close to that end-of-life would seem to be an implicit acknowledgement that, well, somebody screwed the pooch. This is a pretty clear indicator that, as much as Microsoft would love to see VB6 die, they’ve come to a realization that maybe, just maybe, people have very good reasons to continue using code that works. Maybe this realization will be the kick in the pants for Microsoft to not pull stupid semantic tricks with future VBs that break all sorts of backwards compatibility, again. Hmmm, and maybe Chuck E. Cheese will one day be a fun place for adults to hang out, too.

But, by far the biggest news to hit me square in the jaw was the VB group’s plans to have VB10, er, VBx written in VB itself! For me, this is simply huge. I’ve always said there are a certain fundamental class of problems a compiler presents that a good language should be able accommodate, and finally, VB will become one of those languages. I for one, have heard one too many times “If VB was any good, it’d be written in VB.” ‘Bout damn time!

Of course, there’s this troubling passage on the blog

“Currently VBx is in very early stages, and is a long way off from production. In fact, most of our development team is actively working on VB 9.”

Doh. Well, so VB get’s real when I finally get my flying car (that’s this one, not this one)

Vista and Intranet Application Security

5
Filed under Security, Vista

On my setup, I have a file server with a RAID that generally is a bare (but SP’d and updated) Win2003 server install, ie a very minimal installation. At one point I set up ADS with a domain, DNS, etc. Nowadays, I still setup the DNS server on this box, but generally don’t make use of ADS, in my (albeit weak) attempt at simplification.

On my workstations, I install Win2000/XP/Vista in Workgroup mode and use identical passwords and user accounts on the server and each workstation. That way, legacy login support kicks in and login validations still apply, but I don’t have to mess with ADS and domains to make it happen. Not as secure as ADS, but not completely open either. 

One thing I tend to do, when possible, is install apps to a network drive and run them from there. I say when possible because for those apps that require COM registration, etc, this doesn’t work too well. But there are plenty of apps that work just fine this way, including Trillian, Keepass, InfoSelect, NotePad++, IrfanView, etc. Keeps me from having to reinstall and redo configuration.

With the latest install of Vista, however, I was getting a “Are you sure” dialog like this every time I went to run an app off a server share.

image

Now, before people start screaming “Good Lord, don’t turn that off, there’s no telling what might have replaced that app out on the network! How do you know it’s safe?!”, the fact is that my entire network runs behind a firewall, and all machines run NOD32. If something infected an app out on the server share, it’s just as likely to have already infected my local workstation anyway.

I’d rather not have to “accept” running any app off the server every time I want to, so what I needed was a way to tell Windows, “Hey, it’s OK to run files from these locations, I’m fairly certain they’re safe”.

Come to find out, such a setting exists, of all places, in the Internet Settings area of the Control Panel:

image

image 

Make sure the Local Intranet security is medium-low or lower. This is the default though, and doesn’t appear to need to be changed.

image 

image 

At this point, just enter the UNC of your server, say \\MyServer (you only need to enter the root server name, unless you specifically don’t trust certain shares on your server, in which case you could specify the server and share name, such as \\MyServer\MyTrustedShare.

image 

And that’s it.

If there are any significant security issues with this approach, I’m not seeing them. I have to trust my server as much as my workstations (if not more, since I rarely actually install any software on my server. Anybody care to enlighten me?

Ultra-Speed Wonder-Blogging

0
Filed under Blogging, Utilities

I’ve read a ton of good press about BlogJet and from the demo I looked at it’s pretty slick. But BlogDesk is free and does everything I needed it to, until now.

I have to say, Windows Live Writer is an awfully nice way to write blogs, and it’s free as well. It works smashingly with dasBlog, sets up on Vista without a hitch, has a built in spell checker, which myself (and a lot of blog writers out there) need, and can even edit blog entries using the styles cribbed from you blog itself.

Check out this screenshot of Live Writer entering this actual entry.

image

Sweetness. And it pulled the style sheets automatically. It doesn’t look exactly  like my blog, but hey, that’s pretty good for being editable!

Finally, if you prefer, there’s all sorts of effects you can give graphics as you paste them in. I tend towards the simplistic, but there’s drop shadows, overlays, transforms, etc to play with.

UPDATE: Well, Live Writer is nice, but it’s definitely still beta. With lots of images, it seems to crash when loading drafts to continue editing. But it works well enough for image-light pages, so your mileage may vary.