extract.vbs
来自「Apress - Managing Enterprise Systems Wit」· VBS 代码 · 共 31 行
VBS
31 行
'extract.vbs
Dim objSession, objMsgColl, objMessage, strFile
Set objSession = CreateObject("MAPI.Session")
' supply a valid profile
objSession.Logon "Valid Profile"
'get a reference to the InBox messages
Set objMsgColl = objSession.InBox.Messages
'filter all unread messages
objMsgColl.Filter.Unread = True
'loop through the Messages collection and extract attachment for any messages
'that meet the filter criteria
Set objMessage = objMsgColl.GetFirst()
Do While Not objMessage Is Nothing
WScript.Echo objMessage.Subject, objMessage.Attachments.Count
For Each objAttachment In objMessage.Attachments
strFile = objAttachment.Source
If strFile <> "" Then
strFile = Mid(strFile,InstrRev(strFile,"\") + 1)
objAttachment.WriteToFile "d:\data\" & strFile
End If
Next
objMessage.Unread = False ' flag message as read
objMessage.Update 'update message
'get the next message
Set objMessage = objMsgColl.GetNext()
Loop
objSession.Logoff
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?