我正在尝试将Excel文件复制到Outlook文件夹。我可以找到Outlook文件夹,但无法弄清楚如何在其中复制excel文件。
Const olFolderInbox = 6
set fso = CreateObject("Scripting.FileSystemObject")
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNamespace.Folders("ServiceDesk Support")
Set colItems = objInbox.Items
sourcefolder = "c:\"
strfilename = "Online Status -Test.xlsx"
sourcefile = "C:\Online Status -Test.xlsx"
set strfile = fso.GetFolder(sourcefolder)
GetSubfolders(objInbox)
Sub GetSubfolders(objParentFolder)
Set colFolders = objParentFolder.Folders
For Each objFolder in colFolders
Set objSubfolder = objParentFolder.Folders(objFolder.Name)
if objSubfolder = "File Status" then
set savefolder = objSubfolder
fso.CopyFile sourcefile, objSubfolder.Name
end if
GetSubfolders objSubfolder
Next
End Sub
脚本成功完成,但是Outlook文件夹中没有文件。