'"C:empOutlookAttachments",它没有错误处理所以请小心使用!
'以下是代码(放在一个Command按钮下面)
DimoAppAsOutlook.Application
DimoNameSpaceAsNameSpace
DimoFolderAsMAPIFolder
DimoMailItemAsObject
DimsMessageAsString
SetoApp=NewOutlook.Application
SetoNameSpace=oApp.GetNamespace("MAPI")
SetoFolder=oNameSpace.GetDefaultFolder(olFolderInbox)
ForEachoMailItemInoFolder.Items
WithoMailItem
IfoMailItem.Attachments.Count0Then'?
oMailItem.Attachments.Item(1).SaveAsFile"C:TempOutlookAttachments"&oMailItem.Attachments.Item(1).filename
MsgBoxoMailItem.Attachments.Item(1).DisplayName&"wassavedas"&oMailItem.Attachments.Item(1).filename
EndIf
EndWith
NextoMailItem
SetoMailItem=Nothing
SetoFolder=Nothing
SetoNameSpace=Nothing
SetoApp=Nothing
作者:LewisCornick
邮箱:l_cornick@hotmail.com
网址:http://www.geocities.com/SiliconValley/Haven/1768