VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 把Outlook信箱中的附件另存为
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8902, 日期:2001-07-01
把Outlook信箱中的附件另存为
作者:Lewis Cornick
注释:这点代码将会找到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\OutlookAttachments\" & oMailItem.Attachments.Item(1).filename
        MsgBox oMailItem.Attachments.Item(1).DisplayName & " wassaved as " & oMailItem.Attachments.Item(1).filename
      End If
    End With
  Next oMailItem

Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
作者:Lewis Cornick
邮箱:l_cornick@hotmail.com
网址:http://www.geocities.com/SiliconValley/Haven/1768