32/64-bit compatible version of Outlook Attachment Manager

User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

32/64-bit compatible version of Outlook Attachment Manager

Post by HansV »

Update history:
  • 04-Jan-2011: First 32/64-bit compatible version.
  • 06-Jan-2011: Bug fix to prevent formatting being removed from HTML messages in Outlook 2007 and higher.
    Warning: Formatting will still be removed from Rich Text format messages in ALL versions of Outlook.
  • 10-Jan-2011: Added possibility to create a new folder in the folder browse dialog.
Some years ago, Goshute aka JohnBF posted a great utility in Woody's Lounge to save Outlook attachments and (optionally) replace them with hyperlinks: the Outlook Attachment Removal Manager.

I created a slightly modified version of this utility that is being used successfully by me and my colleagues at work. Recently, one of my colleagues got a new laptop with 64-bit Office 2010, and the utility had to be updated to work with 64-bit Windows API calls.

The updated version works in Outlook 2002, Outlook 2003, Outlook 2007 and both 32-bit and 64-bit Outlook 2010.

If you look at the code of the basCallBacks module in the Visual Basic Editor, you'll notice that parts of the code will be displayed in red because it's not valid for your version of Office. The code uses conditional compilation with

#If VBA7 Then
...
#Else
...
#End If

to run the correct code depending on the version.
OLAttachMan7.zip
You do not have the required permissions to view the files attached to this post.
Last edited by HansV on 10 Jan 2011, 08:39, edited 3 times in total.
Reason: New Version
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

Wonderful, thank you. I have just installed this on my 32 bit Windows 7 laptop and it works perfectly.
StuartR


User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by Goshute »

Thank you, Hans, for maintaining, updating, and improving this tool.
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

Goshute wrote:Thank you, Hans, for maintaining, updating, and improving this tool.
And thank you John for creating the code in the first place.
StuartR


User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

StuartR wrote:And thank you John for creating the code in the first place.
I second that! I merely tweaked John's excellent code. I have learned much about Outlook's object model by studying it.
Best wishes,
Hans

User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by Goshute »

Let's not forget that though I did the grunt work :grin:, I had a lot of help from Rory A., Jefferson S., and Hans V. with the product; Jefferson introduced me to the Outlook object model, Rory helped with a number of things including the dialogs and HTML text body coding, and Hans refined and improved my code in a number of ways, especially with improved object qualification (which is always a weakness of mine because I lean a more to concision than comprehensibility in my code). I stand on the shoulders of those who taught me.
Goshute
I float in liquid gardens

User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

We're quite an acrobatic team: I stand on your shoulders, you on mine... :laugh:
Best wishes,
Hans

User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by Goshute »

I guess it helps that I was born down under. :laugh:
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

It all sounds a bit kinky to me
StuartR


User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

Let's not take this too far... :evilgrin:
Best wishes,
Hans

User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by Goshute »

:rofl:
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

StuartR wrote:Wonderful, thank you. I have just installed this on my 32 bit Windows 7 laptop and it works perfectly.
I have now used this a bit more, and there are some problems with it. This is on Office 2010, Vista Enterprise 32 bit.
  • All text in the message reverts to my default font. Applied font styles, sizes and colors are discarded.
  • Embedded graphics in the mail are replaced with a description, even if I have not selected them to be saved.
  • Hyperlinks in the message (such as email addresses) are replaced with HYPERLINK "mailto:..." etc.
StuartR


User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

Sorry, I can't explain that. It doesn't behave that way in Outlook 2002 on Windows XP, Outlook 2003 on Windows XP, Outlook 2007 on Windows 7 or 64-bits Outlook 2010 on Windows 2008 Server. I don't have access to any PC with 32-bits Outlook 2010.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

If I single step the code then the reformatting occurs when this line is executed.
.Body = strHLinkText & vbCrLf & .Body

I will try installing the attachment manager on my PC running 32 bit Office 2007 and see if it works there.

Edited by StuartR to add...
It behaves the same on my Vista 32 bit Outlook 2007 as well. I have just tried it with a document in a PST file to see if that behaves differently to one on the Exchange server, but that behaves the same too.

I guess it must be something to do with how Outlook is configured, or an add-on that my employers have installed. When I get a chance I will try it on a personal PC to see if that behaves differently.

Edited again to add...
It behaves the same on a home PC, Outlook 2007 on Windows 7 64 bit with none of my employers stuff installed
StuartR


User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

Oh wait - do you use Rich Text format? I fear the code has only been tested on HTML and Plain Text formats.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

HansV wrote:Oh wait - do you use Rich Text format? I fear the code has only been tested on HTML and Plain Text formats.
I usually use HTML format, the only RTF stuff I have is meeting requests.
StuartR


User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by HansV »

I'll see if I can find something when I'm back home, where I have Outlook 2007.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

HansV wrote:I'll see if I can find something when I'm back home, where I have Outlook 2007.
I have sent you an example before and after email, in case there is something really silly I have missed in the formatting.
StuartR


User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by Goshute »

Hans, I suspect that because of MS's decision to use Word as sole Editor the Outlook Object Model has been made more "precise" as to MailItem.Body content since the 2002/2003 platform that the tool was developed on. So in Outlook 2007 and 2010, rather than using:

MailItem.Body = <something in any format>

it may now be necessary to use the correct Body Format when Body text is manipulated:

MailItem.Body = <something in plain text or RTF>
MailItem.HTMLBody = <something in HTML>

See generally http://msdn.microsoft.com/en-us/library/bb176688(v=office.12%29.aspx" onclick="window.open(this.href);return false; including http://msdn.microsoft.com/en-us/library/bb208058(v=office.12%29.aspx" onclick="window.open(this.href);return false; http://msdn.microsoft.com/en-us/library ... 12%29.aspx" onclick="window.open(this.href);return false; and http://msdn.microsoft.com/en-us/library/bb175500(v=office.12%29.aspx" onclick="window.open(this.href);return false;

(I really need to get an updated version of Sue Mosher's book. I am at present in Lotus Notes at work and Outlook 2003 at home, but hope to be back in a corporate Outlook 2010 environment in the next few months, so I'll be able to test the tool in Outlook 2010 when that happens.)
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12601
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 32/64-bit compatible version of Outlook Attachment Manag

Post by StuartR »

John,

The code does use .HTMLBody rather than .Body if a variable boolHTMLFormat is true. This is set by the line
boolHTMLFormat = (objItem.GetInspector.EditorType = olEditorHTML)
and is always false on my computers, because objItem.GetInspector.EditorType is olEditorWord

If I use the immediate window to set boolHTMLFormat to be true then the behaviour is right.
StuartR