LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to extract excel attachment from outlook email


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.
 
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
Add attachment to an already open Outlook email Nathan Berton Excel Programming 5 April 17th 08 06:44 PM
Email a file as an attachment in Outlook 2000 using Excel VB macro Freddy Excel Programming 11 July 11th 07 04:54 PM
Send an email attachment (pdf file) from Excel 2003 using Outlook Express [email protected] Excel Programming 6 November 16th 06 03:02 PM
Excel Spreadsheet email attachment unable to open in Outlook Expr. Joanne from Tiffin, Oh Excel Discussion (Misc queries) 1 April 23rd 05 12:21 AM
Email Attachment from Excel using Outlook. Pyball[_3_] Excel Programming 2 December 17th 03 07:08 PM


All times are GMT +1. The time now is 08:35 AM.

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

About Us

"It's about Microsoft Excel"