tanfidzularus
New Member
- Joined
- Feb 15, 2014
- Messages
- 1
I build a tools that copied from ron de bruin win tips and adjust it according to my need. https://www.rondebruin.nl/win/s1/outlook/saveatt.htm But after i changed my pc (before using win 7 and office 2007) and upgrade the os, it doesnt work any more. Now im using win 10 and office 2010 Especially script that "saving attachment" It keeps pop up and showing error no 48, error loading dll. I google it and not find any specific solution about my problem.
Hoping somebody could please gives advice
Code:
Sub SaveAttachments()
Dim ns As Namespace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim Filename As String
Dim MyDocPath As String
Dim I As Integer
Dim wsh As Object
Dim fs As Object
On Error GoTo ThisMacro_err
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set SubFolder = Inbox.Folders("Delete")
Set MyEmails = SubFolder.Items
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
I = 0
If SubFolder.Items.Count = 0 Then
MsgBox "Tidak ada email baru pada folder: " & SubFolder, vbInformation, "CDCM"
Set SubFolder = Nothing
Set Inbox = Nothing
Set ns = Nothing
Exit Sub
End If
If DestFolder = "" Then
Set wsh = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
MyDocPath = ActiveWorkbook.path
DestFolder = MyDocPath & "\Delete Collective"
If Not fs.FolderExists(DestFolder) Then
fs.CreateFolder DestFolder
End If
End If
For Each Item In SubFolder.Items
DoEvents
If (Item.Class = olMail) And (Item.UnRead) = True Then
For Each Atmt In Item.Attachments
If Left(Atmt.Filename, 17) = "Delete Collective" And Right(Atmt.Filename, 4) = ".xls" Then
Filename = DestFolder & Atmt.Filename
Atmt.SaveAsFile Filename
I = I + 1
End If
Next Atmt
End If
Item.UnRead = False
Next Item
If I > 0 Then
MsgBox "Attachment sudah disimpan ", vbInformation, "CDCM"
Else
MsgBox "Attachment tidak ditemukan atau email sudah dibaca(Read)", vbInformation, "CDCM"
End If
MoveAgedMail
ThisMacro_exit:
Set SubFolder = Nothing
Set Inbox = Nothing
Set ns = Nothing
Set fs = Nothing
Set wsh = Nothing
Exit Sub
ThisMacro_err:
MsgBox "Ups,an unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description, vbCritical, "Error!"
Resume ThisMacro_exit
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Last edited by a moderator: