把Outlook信箱中的附件另存为

资讯 驱动中国 若水 2,959 次阅读 0 条评论
分享 Q

'Author: Lewis Cornick

'Date : 04/22/98

'http://www.geocities.com/SiliconValley/Haven/1768

'E-Mail:l_cornick@hotmail.com

'Description: To be used in 'stripping' attachments from

'e-mails in your inbox and save them to a hardcoded path.

'This bit of code will strip attachments and save them into the path

'"C:\temp\Outlook Attachments", it has no error handling so be warned!

'Code starts (placed under a command button.)

'这点代码将会找到Outlook信箱中的附件,并把它们保存至

'"C:\temp\Outlook Attachments",它没有错误处理所以请小心使用!

'以下是代码(放在一个Command按钮下面)

Dim oApp As Outlook.Application

Dim oNameSpace As NameSpace

Dim oFolder As MAPIFolder

Dim oMailItem As Object

Dim sMessage As String

Set oApp = New Outlook.Application

Set oNameSpace = oApp.GetNamespace("MAPI")

Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)

For Each oMailItem In oFolder.Items

With oMailItem

If oMailItem.Attachments.Count > 0 Then '?

oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\Outlook

Attachments\" & oMailItem.Attachments.Item(1).filename

MsgBox oMailItem.Attachments.Item(1).DisplayName & " was

saved as " & oMailItem.Attachments.Item(1).filename

End If

End With

Next oMailItem

Set oMailItem = Nothing

Set oFolder = Nothing

Set oNameSpace = Nothing

Set oApp = Nothing

版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友