Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #107974

How to extract excel attachment from outlook email

Newsgroups microsoft.public.excel.programming
Date 2015-08-17 01:58 -0700
Message-ID <33db03c3-7395-4cd1-9dc1-d364606f3dc6@googlegroups.com> (permalink)
Subject How to extract excel attachment from outlook email
From misbah.ali786@gmail.com

Show all headers | View raw


Hi, I am writing to seek help as I would like to add the following functionalities to the code below but I am not sure how to go about doing so as I found this code from a sample application.  

Additional logic:
-----------------
*	Only extract attachments for the following formats: xls, xlsx & csv
*	Extract attachment only with from yesterday sent date (emails). 


Here is my current code which is currently not outputting anything:

Sub GetAttachments()

 Dim ns As NameSpace
 Dim Inbox As MAPIFolder
 Dim Item As Object
 Dim Atmt As Attachment
 Dim FileName As String
 Dim i As Integer
 Dim myExt As String
 
 Set ns = GetNamespace("MAPI")
 Set Inbox = ns.GetDefaultFolder(olFolderInbox).Folders("Offer")
 i = 0

If Inbox.Items.Count = 0 Then
    MsgBox "There are no messages in the Inbox.", vbInformation, _
           "Nothing Found"
    Exit Sub
 End If
 
 For Each Item In Inbox.Items
    For Each Atmt In Item.Attachments
    
      Select Case myExt
       Case "xls", "xlsm", "xlsx"
                
       FileName = "C:\Users\missy\Desktop\Outlook_files\" & Atmt.FileName
       Atmt.SaveAsFile FileName
       i = i + 1
    'Case Else
            'do nothing
            End Select
    Next Atmt
 Next Item

GetAttachments_exit:
   Set Atmt = Nothing
   Set Item = Nothing
   Set ns = Nothing
   Exit Sub

End Sub


Any further help or feedback would be very much appreciated.  Many thanks for your time and help. 

Back to microsoft.public.excel.programming | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How to extract excel attachment from outlook email misbah.ali786@gmail.com - 2015-08-17 01:58 -0700
  Re: How to extract excel attachment from outlook email isabelle <i@v.invalid> - 2015-08-18 13:01 -0400

csiph-web