Advertisement
Advertisement
| 07.09.2008 at 07:20AM PDT, ID: 23550313 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: |
Dim otlApp As Outlook.Application
Dim otlNMSpace As Outlook.NameSpace
Dim otlFolder As Outlook.MAPIFolder
Dim otlSubFolder As Object
Dim otlItem As Object
Dim otlMailItem As Outlook.MailItem
Dim otlAttachment As Outlook.Attachment
Dim strFilePrefix As String
Set otlApp = CreateObject("Outlook.Application")
Set otlNMSpace = otlApp.GetNamespace("mapi")
Set otlFolder = otlNMSpace.GetDefaultFolder(olFolderInbox)
If Not otlFolder Is Nothing Then
For Each otlItem In otlFolder.Items
If otlItem.Class = olMail Then
Set otlMailItem = otlItem
If otlMailItem.Attachments.Count > 0 Then ' thus only if mail has attachment !!
Debug.Print otlMailItem.Subject, otlMailItem.ReceivedTime, otlMailItem.SenderName
strFilePrefix = Right$(otlMailItem.Subject, 2)
For Each otlAttachment In otlMailItem.Attachments
If otlAttachment.FileName = "strPrefix" & "000x.txt" Then
otlAttachment.SaveAsFile "C:\MyFolder\" & strFilePrefix & "\" & otlAttachment.FileName
End If
Next otlAttachment
End If
End If
Next
End If
Set otlApp = Nothing
Set otlNMSpace = Nothing
Set otlFolder = Nothing
|