我将收到的物品保存在硬盘上,并以不同的方式命名它们。
尝试将项目导入回Outlook会给我一个错误:
编译错误 未定义用户定义类型。
上
将文件夹调暗为展望文件夹
在我的第一个模块中
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim Savefolder As String
Savefolder = "c:temp"
For Each objAtt In itm.Attachments
stFileName = Savefolder & "" & objAtt.DisplayName
i = 0
JumpHere:
If Dir(stFileName) = "" Then
objAtt.SaveAsFile stFileName
Else
i = i + 1
stFileName = Savefolder & "" & objAtt.DisplayName & " - " & i
GoTo JumpHere
End If
Set objAtt = Nothing
Next
End Sub
在我的第二个模块中
Sub ImportMessagesInFolder()
Dim fso As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder
Dim SourceFolderName As String
Dim FileItem As Scripting.file
Dim strFile, strFileType As String
Dim oMsg As Object
Dim copiedMsg As MailItem
Dim Savefolder As Outlook.Folder
Set fso = New Scripting.FileSystemObject
'Source folder
SourceFolderName = "C:temp"
Set SourceFolder = fso.GetFolder(SourceFolderName)
'Set the Outlook folder name
Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("Extra")
Set Savefolder = Application.ActiveExplorer.CurrentFolder
For Each FileItem In SourceFolder.Files
Set oMsg = Session.OpenSharedItem(FileItem.Path)
On Error Resume Next
Set copiedMsg = oMsg.Copy
copiedMsg.Move Savefolder
Set copiedMsg = Nothing
oMsg.Delete
Set oMsg = Nothing
Next FileItem
Set FileItem = Nothing
Set SourceFolder = Nothing
Set fso = Nothing
End Sub
请改用Outlook.MAPIFolder
。