个位大侠,不是每个人都是程序员的,对我,这个homework复杂了点,多年不编程序了,借助HELP,鼓捣一下,还成,给我鼓掌吧
Sub TraverseMail()
Dim ns As NameSpace
Dim PubBox, Inbox As MAPIFolder
Dim intFile As Integer
Dim Subject, From As String
Dim DateTime As Date
Set ns = GetNamespace("MAPI")
Set PubBox = ns.GetDefaultFolder(olFolderOutbox)
Set Inbox = PubBox.Folders(2)
MsgBox (Inbox)
intFile = FreeFile
If Inbox.Items.Count > 0 Then
Open "C:\TempTest.txt" For Output As intFile
For Each Item In Inbox.Items
' If Item <> Null Then
Subject = Item.Subject
From = Item.SenderName
DateTime = Item.ReceivedTime
Print #intFile, Subject + " | " + From + " | " + FormatDateTime(DateTime) ' append content to a file
' End If
Next Item
Close intFile
Else
MsgBox "There is no message in the box."
End If
End Sub
Sub TraverseMail()
Dim ns As NameSpace
Dim PubBox, Inbox As MAPIFolder
Dim intFile As Integer
Dim Subject, From As String
Dim DateTime As Date
Set ns = GetNamespace("MAPI")
Set PubBox = ns.GetDefaultFolder(olFolderOutbox)
Set Inbox = PubBox.Folders(2)
MsgBox (Inbox)
intFile = FreeFile
If Inbox.Items.Count > 0 Then
Open "C:\TempTest.txt" For Output As intFile
For Each Item In Inbox.Items
' If Item <> Null Then
Subject = Item.Subject
From = Item.SenderName
DateTime = Item.ReceivedTime
Print #intFile, Subject + " | " + From + " | " + FormatDateTime(DateTime) ' append content to a file
' End If
Next Item
Close intFile
Else
MsgBox "There is no message in the box."
End If
End Sub