Welcome to Office Zealot Sign in | Join | Help

Handling RFC 822 Date/Time in VB.NET

I've been working on a project that involved retrieving an RFC 822 Date/Time value in a string.  I needed to correctly convert that to a Date value, so I thought that would be very painless and off I went:

 

returnedDateString = "Tue, 13 May 2008 12:09:08 -0700 (PDT)"

myDate = returnedDateString.ToDate

 

Haha!  I wish…

 

Okay, next:

 

myDate  = CType(returnedDateString , Date)

 

Why the hell not?  Oh well.  NEXT!

 

myDate.FromString = ...

 

I'm nothing if not optimistic.  Okay, research time.  Now, I've done far too much VB6 and VBA compared to VB.NET and it's going to take me a few more years to get out of that mindset (I got my MCSD in 1999, after all).  Some of you may have figured this out already.

 

Anyway, I quickly narrowed it down to Date.Parse or Date.ParseExact or Date.TryParse or Date.TryParseExact.  The Parse methods don't allow any kind of standard or custom date and time format strings, and they puke on this complicated example.  So the answer lies with TryParseExact (TryParse will throw an exception, TryParseExact won't).

 

After looking at the different standard format strings, I thought I was in luck because "R" or "r' is  the shortcut identifier for RFC1123 dates.  Oh.  That's for this kind of pattern:

 

ddd, dd MMM yyyy HH':'mm':'ss 'GMT'

 

Okay.  Looks like I have to build this format string myself.  Here's the RFC 822 Date/Time spec from w3.org:

 

date-time   =  [ day "," ] date time        ; dd mm yy
                                            ;  hh:mm:ss zzz

day         =  "Mon"  / "Tue" /  "Wed"  / "Thu"
            /  "Fri"  / "Sat" /  "Sun"

date        =  1*2DIGIT month 2DIGIT        ; day month year
                                            ;  e.g. 20 Jun 82

month       =  "Jan"  /  "Feb" /  "Mar"  /  "Apr"
            /  "May"  /  "Jun" /  "Jul"  /  "Aug"
            /  "Sep"  /  "Oct" /  "Nov"  /  "Dec"

time        =  hour zone                    ; ANSI and Military

hour        =  2DIGIT ":" 2DIGIT [":" 2DIGIT]
                                            ; 00:00:00 - 23:59:59

zone        =  "UT"  / "GMT"                ; Universal Time
                                            ; North American : UT
            /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
            /  "CST" / "CDT"                ;  Central:  - 6/ - 5
            /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
            /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
            /  1ALPHA                       ; Military: Z = UT;
                                            ;  A:-1; (J not used)
                                            ;  M:-12; N:+1; Y:+12
            / ( ("+" / "-") 4DIGIT )        ; Local differential
                                            ;  hours+min. (HHMM)

 

To make a longer story thus far slightly shorter, I came up with this:

 

Date.TryParseExact(strDateNoGMT, "ddd, d MMM yyyy HH:mm:ss zzz", Nothing, Globalization.DateTimeStyles.AssumeUniversal, myDate)

 

What's strDateNoGMT?  Well, unless I'm mistaken, there are no custom date/time format strings that can handle the trailing GMT value, so I had to strip it out:

 

strDateNoGMT = returnedDateString .RemovereturnedDateString.IndexOf("("), 5).Trim

 

Hopefully this helps someone out, as I couldn't find any examples.  Apparently RSS apps have to deal with RFC 822 Date/Time strings frequently, so maybe this will save some RSS dev out there who's fighting over the same problem.

Posted by legault | 0 Comments
Filed under:

Vista Annoyance - Open/Save As Choices For File Downloads

 

Finally - after months of occasional efforts to find a solution (poor searching maybe), and seeing "close but no cigar" workarounds for general file association issues in Vista, I've deduced the answer to a problem that's been bugging me for months.

 

At some point, I was no longer presented with the option to Open or Save a .zip file from a link on a web page.  I really don't like .zip files being directly opened in WinZip, because it will be saved to your %temp% directory and then you have to copy the archive to where you actually want to save it.  Plus, the continuous insertion of [1] after the file name drives me mad, never mind the stupid bug/feature in WinZip that prevents me from moving the archiving and forces me to copy it - leaving junk behind.  But I digress from my rant…

 

The setting that remembers your Open/Save choice is in this key:

 

HKEY_CLASSES_ROOT\WinZip\EditFlags

 

These are the REG_BINARY value:

 

00 00 01 00 = Open

00 00 00 00 = Save As

 

Easy!  The action for other file types can be similarly changed.  With Word 2007 docs for example, look in HKEY_CLASSES_ROOT\Word.Document.12\EditFlags.

 

But remember how much easier this was to change in Windows XP?  <sigh>

Posted by legault | 0 Comments
Filed under:

Changing Outlook's Macro Security Settings

 

If you ever have a need to programmatically change Outlook's macro security settings (or to change it outside of Outlook), you can do so by editing the values of this key in the Windows Registry:

 

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security\Level

 

These are the settings in Outlook's Macro Security dialog and the corresponding values:

 

Setting

Value

No warnings and disable all macros

4

Warnings for signed macros; all unsigned macros are disabled

3

Warnings for all macros

2

No security check for macros (Not recommended)

1

 

If you change the value while Outlook is running, the change will be reflected in the dialog but the changes won't be applied until after you restart Outlook.

Posted by legault | 3 Comments
Filed under:

Take SharePoint Content Offline Without the Hassle

As a value added service to customers who have implemented (or will) SharePoint in their organization, I have established a relationship with Colligo Networks, Inc. as an official Colligo for SharePoint Partner.  I am now the sole integrator for Colligo in the Winnipeg and Manitoba regions.

 

As  a developer and integrator, I am speciliazing in solutions utilizing Colligo's flagship software - Colligo Contributor™ Pro.  This is an easy-to-deploy .NET client application that extends the power of SharePoint to the desktop.  It can boost productivity and adoption by enabling users to instantly and securely access, modify and create SharePoint content online and offline.  Contributor Pro includes two user interface options: a rich standalone desktop client and an Outlook Add-in.

 

As you probably know, Outlook 2007 provides support for linking SharePoint Lists and Document Libraries.  But as the following table shows, Contributor offers much more:

 

Requirements

SharePoint

+ Outlook 2007

SharePoint+ Groove 2007

SharePoint

+ Colligo Contributor

Drop content into Document Libraries through Outlook folders

 

 

Yes

Offline cache, 2-way sync of custom lists

 

 

Yes

Offline cache, 2-way sync of Document Libraries

 

Yes

Yes

Apply standard and custom metadata at time of capture

 

 

Yes

Automatically extract email message properties to metadata

 

 

Yes

Contributor could be of great value for your organization - not only for offline access to SharePoint content, but also for:

  • Remote offices where bandwidth is an issue
  • User-based migration of Exchange Public Folders to SharePoint using Outlook
  • Email collaboration or archival in SharePoint, especially for compliance and retention policies and regulations

If you would like to experience the power of Colligo's offline access to SharePoint for yourself, download the free Colligo Reader.  It's a great way to try the rich offline SharePoint experience that Contributor Client delivers.  Reader provides read-only access to SharePoint content offline, including documents, lists and metadata.  It's also very simple to use, and would require virtually no training or support for most end-users.

For more information about my consulting services for SharePoint, please drop me a line.

Posted by legault | 1 Comments
Filed under: , ,

Announcing - Picture Attachments Wizard 2.0

 

The next version of my "flagship" Outlook Add-In, Picture Attachments Wizard 2.0 for Microsoft Outlook®, has officially been released!

 

  • Now includes support for Windows Vista
  • Optimized for Outlook 2007 (all previous Outlook versions 2000 and greater are still supported)
  • New image conversion features
  • Performance enhancements
  • And much, much more!

 

Product Highlights:

 

  • View thumbnails of image attachments - without having to save the attachments to disk!
  • Run a slideshow of attached picture files - without having to save the attachments to disk!
  • Quickly save all attachments to a folder with one click!
  • Easily export every attachment in every message in the current folder.
  • Preview image attachments as you add them to a new e-mail message - don't send the wrong picture again!
  • Convert image attachments to a variety of common image formats, then export them to a file or update the attachments directly in the e-mail
  • View the extended file properties of images that were taken with a digital camera (camera model, date picture taken, exposure time, etc.)
  • Works with all common image files (.bmp, .emf, .gif, .jpg, .png, .tif, .wmf)
  • Choose the viewer application to view individual pictures - don't get stuck with the default application that Windows uses! Choose a tabbed web browser to quickly load all of the pictures, or open them with a powerful image editor to quickly make changes.
  • Save disk space by quickly deleting unnecessary attachments of any kind from the selected messages

 

For more information, see the Picture Attachments Wizard 2.0 web site.

 

Or click here to purchase...

Or download a 45-day trial version...

Posted by legault | 1 Comments
Filed under: ,
More Posts Next page »