首页 > 其他 > 详细

msg文件导入到outlook中 ,outlook中运行

时间:2020-03-20 13:26:28      阅读:249      评论:0      收藏:0      [点我收藏+]
Sub ImportMessagesInFolder()
Dim xSourceFldPath As String
Dim xMSG As Object
Dim xMailItem As MailItem
Dim xSaveFld As Outlook.Folder
‘ copy to outlook vba, to import msg file into outlook
‘need to add microsoft scripting runtime into the Tools references
On Error Resume Next
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xSelFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Select a folder:", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
    xSourceFldPath = xSelFolder.self.Path + "\"
Else
    xSourceFldPath = ""
End If
Set xSourceFld = xFSO.GetFolder(xSourceFldPath)
Set xSaveFld = GetObject("", "Outlook.Application").GetNamespace("MAPI").PickFolder
If TypeName(xSaveFld) = "Nothing" Then
    Exit Sub
End If
For Each xFileItem In xSourceFld.Files
    Set xMSG = Session.OpenSharedItem(xFileItem.Path)
    Set xMailItem = xMSG.Copy
    xMailItem.Move xSaveFld
    Set xMailItem = Nothing
    xMSG.Delete
    Set xMSG = Nothing
Next xFileItem
Set xFileItem = Nothing
Set xSourceFld = Nothing
Set xFSO = Nothing
End Sub

 

msg文件导入到outlook中 ,outlook中运行

原文:https://www.cnblogs.com/sundanceS/p/12530109.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!