Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / March 2004

Tip: Looking for answers? Try searching our database.

Attachment Issue - Expert needed for this one

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 24 Mar 2004 17:22 GMT
Please help I spent way to much time trying to figure this
one out.

I created a module to cycle through my inbox and then save
any attachments with extension .aud .swb .a2k. to a
directory folder.

Their is nothing wrong with the code.  The issue is that
outlook says some of these messages contain an extra
attachment then what I see.  i.e. I physically see 2
attachments but outlook see's 3.  Then my code fails
because outlook says it cannot do this of action on this
type of attachment.

Does anyone know why this is?

Here is my code, I am positive it is correct because it
works when it does not encounter a message with this
problem of hidden attachments.

Sub SaveAttachment()

Dim iAttachCnt As Integer
Dim olns As Outlook.NameSpace
Dim oAttachments As Outlook.Attachments
Dim ol As Outlook.Application
Dim message As Object
Dim iTotalAttachSave As Integer

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set myFolder = olns.Folders("My Personal Folder") 'Name of
Main Folder where inbox is included, folder name is case
sensitive.
Set myFolder2 = myFolder.Folders("Inbox").Items 'Inbox name

For Each message In myFolder2
   
 With message.Attachments

   If iAttachCnt > 0 Then
       For iCtr = 1 To iAttachCnt
           
           If .Item(iCtr).FileName Like "*.A2K" Or _
           .Item(iCtr).FileName Like "*.SWB" Or _
           .Item(iCtr).FileName Like "*.AUD" Then
               MsgBox .Item(iCtr).FileName
               .Item(iCtr).SaveAsFile "U:\TSG\EXT\AWU\" _
               & .Item(iCtr).FileName
               'Get the total # of attachments added
                   iTotalAttachSave = 1 + iTotalAttachSave
           End If
       
       Next iCtr

  End If
   End With
   
   
Next message

MsgBox "You have added " & iTotalAttachSave & "
attachments to U:\TSG\Ext\AWU\"

'Clear variables
Set message = Nothing
Set oFldr = Nothing
Set olns = Nothing
Set ol = Nothing
Set myFolder2 = Nothing
Set myFolder = Nothing

End Sub

 
.
Sue Mosher [MVP-Outlook] - 24 Mar 2004 17:55 GMT
One way to find out is to add a MsgBox or Debug.Print statements to
determine the name of the attachment that is giving you the error. There
certainly can be attachments that are not visible in the UI.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Please help I spent way to much time trying to figure this
> one out.
[quoted text clipped - 70 lines]
>
> .
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.