Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default opening zip outlook attachments

Hi, I am trying to produce a macro that will allow me to extract
attachments from a saved .msg file. The following code works perfectly
unless the attachment is a .zip. I was wondering if anyone had any
ideas as why it does not detect zip attachments and any possible
solutions. Here's the code:


Option Explicit

Sub Extract()

Dim sMessagePath As String
Dim sSavePath As String
Dim OLApp As Outlook.Application
Dim oMessage As Outlook.MailItem
Dim oMsgAttach As Outlook.Attachment

'----------------------------------------------------------
'Get the path for the .msg file
'----------------------------------------------------------

With Application.FileDialog(msoFileDialogFilePicker)

'only allow a single file to be selected
.AllowMultiSelect = False

.Title = "Select Message File"

'Filter the file list to only
'include .msg files
With .Filters
.Clear
.Add "Message Files", "*.msg"
End With

'If the user selects a file
'record the path,
'otherwise quit execution
If .Show = -1 Then
sMessagePath = .SelectedItems(1)
Else
Exit Sub
End If
End With

'----------------------------------------------------------
Get the save path
'----------------------------------------------------------

With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Title = "Select Save Folder"

If .Show = -1 Then
sSavePath = .SelectedItems(1)
Else
Exit Sub
End If
End With

'----------------------------------------------------------
'Export the attachments
'----------------------------------------------------------

'Create Outlook objects
Set OLApp = New Outlook.Application
Set oMessage = OLApp.CreateItemFromTemplate(sMessagePath)

'Loop through each attachment...
For Each oMsgAttach In oMessage.Attachments

With oMsgAttach
'... save to the destination folder
.SaveAsFile Path:=sSavePath & "\" & .DisplayName
End With
Next oMsgAttach

'Clear object variables
Set OLApp = Nothing
Set oMessage = Nothing
Set oMsgAttach = Nothing

End Sub



Thanks in advance.
P.S. i have had a lot of help on this so my understanding is a little
limited :)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Attachments not opening in Outlook gish Excel Discussion (Misc queries) 1 June 6th 06 09:49 PM
Opening Microsoft Outlook attachments from saved .msg files Rich[_30_] Excel Programming 0 April 19th 06 10:12 AM
Excel Outlook Attachments opening after several errors everytime cito_support Setting up and Configuration of Excel 2 March 13th 06 06:15 PM
unblock .exe attachments in outlook Todd Htutenstine Excel Programming 3 February 3rd 04 11:55 PM
Opening Outlook Express attachments w/Excel Neil[_13_] Excel Programming 2 September 20th 03 12:38 AM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"