Save attached excel files according to certain variables

Friedrichsen

New member
Joined
Dec 14, 2011
Messages
3
Reaction score
0
Points
0
Location
Copenhagen
Hello

I am new to this forum, so forgive me if this is the wrong subforum for this problem.

I have a dreadful and repetitive routine in my job. Every monday i get 2x17 emails with excelfiles that I must save, merge and report to the management.

I am hoping to eliminate the plethra of clicks that relate to doing this mindnumbing task.

Is there a way to save an attachment with a predefined name, according to, lets say, a registry of email-adresses?

Hope it made sence.

Cheers
 
Curious...

Can you set up a rule in Outlook to filter those messages to go directly into a specific folder? If so you could use the following routine (adpated from http://www.vbaexpress.com/kb/getarticle.php?kb_id=522)

Code:
 '###############################################################################
 '### Module level Declarations
 'expose the items in the target folder to events
Option Explicit

Dim WithEvents TargetFolderItems As Items 
 'set the string constant for the path to save attachments
Const FILE_PATH As String = "C:\Temp\"
Const OUTLOOK_FOLDER as String = "Temp"

 '###############################################################################
 '### this is the Application_Startup event code in the ThisOutlookSession module
Private Sub Application_Startup() 
     'some startup code to set our "event-sensitive" items collection
    Dim ns As Outlook.NameSpace

    Set ns = Application.GetNamespace("MAPI") 
    Set TargetFolderItems = ns.Folders.Item( _ 
    "Personal Folders").Folders.Item(OUTLOOK_FOLDER).Items
    
End Sub 

 '###############################################################################
 '### this is the ItemAdd event code
Sub TargetFolderItems_ItemAdd(ByVal Item As Object) 
     'when a new item is added to our "watched folder" we can process it
    Dim olAtt As Attachment 
    Dim i As Integer
  
    If Item.Attachments.Count > 0 Then 
        For i = 1 To Item.Attachments.Count 
            Set olAtt = Item.Attachments(i) 
             'save the attachment
            olAtt.SaveAsFile FILE_PATH & olAtt.FileName
           
            End If 
        Next 
    End If 

    Set olAtt = Nothing
   
End Sub

'###############################################################################
 '### this is the Application_Quit event code in the ThisOutlookSession module
Private Sub Application_Quit()
     
    Dim ns As Outlook.NameSpace 
    Set TargetFolderItems = Nothing 
    Set ns = Nothing 
 
End Sub
 
Back
Top