|
参考一下本帖置顶的VBA集中营。下面的帖子实际上就很容易改造成你所需要的功能。
http://club.excelhome.net/viewthread.php?tid=252928&px=0
以下代码请参考。我测试过,在XP+OUTLOOK2007下运行正常。
Sub Savethemail()
Dim olApp As New Outlook.Application
Dim nmsName As Outlook.NameSpace
Dim fldFolder As Outlook.Folder
Dim vItem As Object
Set nmsName = olApp.GetNamespace("MAPI")
Set fldFolder = nmsName.GetDefaultFolder(olFolderInbox)
If fldFolder.Items.count > 0 Then
For Each vItem In fldFolder.Items
strname = vItem.Subject '
strname = Replace(strname, "*", "_") '
strname = Replace(strname, "\", "_") '
strname = Replace(strname, "/", "_") '
strname = Replace(strname, "$", "_") '
strname = Replace(strname, "%", "_") '
strname = Replace(strname, "!", "_") '
strname = Replace(strname, "~", "_") '
strname = Replace(strname, "(", "_") '
strname = Replace(strname, ")", "_") '
strname = Replace(strname, "+", "_") '
strname = Replace(strname, ":", "_") '
strdate = Format(vItem.SentOn, "yymmdd")
vItem.SaveAs "C:\OLtemp\" & strdate & " - " & strname & ".txt", olTXT '
Next
End If
Set fldFolder = Nothing
Set nmsName = Nothing
End Sub |
|