×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

向大家汇报一下。中午skip午饭,装outlook2003,试轮胎大侠的代码,几经周折,成功了:把Outbox folder下project folder里的信标题打出来了。最后代码见内,修改原因表问我,不改不转,另外

个位大侠,不是每个人都是程序员的,对我,这个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
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / 如何把一个folder里的email的"from"and "subject"按时间顺序导出到文件里?写报告要把一个项目往来邮件列出来,邮件内容不需要,有日期发信人和标题就可以了。我用outlook和mozilla谢
    • 这个容易,刚花了几分,学习了一下,就会写了.
      Dim ns As NameSpace
      Dim Inbox As MAPIFolder


      Set ns = GetNamespace("MAPI")
      Set Inbox = ns.GetDefaultFolder(olFolderInbox)

      If Inbox.Items.Count > 0 Then
      For Each Item In Inbox.Items
      Subject = Item.Subject
      From = Item.SenderName
      Debug.Print Subject + " @ " + From
      Next Item
      Else
      MsgBox "There is no message in the box."
      End If
      • 挖,编程序啊,这太高深了。这VB码在哪里运行?在IE上吗?怎么操作?
        刚才给你戴帽穿靴
        <html>
        <script LANGUAGE="VBScript">
        <--

        。。。。。。。

        -->
        </script>
        </html>

        加载到IE,未遂,别骂我土。
        • 我啥也没说。
          得罪拉,道个谦。

          在Outlook -> Tools -> Macros -> VB Editor 里面run, 又加了几行文件操作

          Sub TraverseMail()

          Dim ns As NameSpace
          Dim Inbox As MAPIFolder
          Dim intFile As Integer
          Dim Subject, From As String

          Set ns = GetNamespace("MAPI")
          Set Inbox = ns.GetDefaultFolder(olFolderInbox)

          intFile = FreeFile

          If Inbox.Items.Count > 0 Then

          Open "C:\Temp\Test.txt" For Output As intFile

          For Each Item In Inbox.Items
          If Item <> Null Then
          Subject = Item.Subject
          From = Item.SenderName
          Print #intFile, Subject + " @ " + From ' append content to a file
          End If
          Next Item

          Close intFile
          Else
          MsgBox "There is no message in the box."
          End If

          End Sub
          • 谢谢大侠啦,是我没说清楚,我是outlook express,没有那个菜单,公司又不让装软件。这个已经存盘,准备找一个没有control的机器试试。。。
            • 惨。
            • do you have ms word? run it in any VB or VBA software.
              • 未遂。Compile error: User-defined type not defined @ "Dim ns as NameSpace" 非Outlook 不行:<
                • I did similar thing in Ms Access. Keep trying.
                • I write the code myself. It is not difficult. I feel lazy to find the source code. Do some homework yourself. please. Your task is rather easy.
                  • 向大家汇报一下。中午skip午饭,装outlook2003,试轮胎大侠的代码,几经周折,成功了:把Outbox folder下project folder里的信标题打出来了。最后代码见内,修改原因表问我,不改不转,另外
                    个位大侠,不是每个人都是程序员的,对我,这个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
                    • GOOD.
                    • COOL
    • 再给你一个不错的ref
      • 放弃,the configuration of this system prevents installing applications, please contact your system administrator....我还是1笔1笔的敲吧,也就几百疯信件。。。
    • 渥太华工作的朋友们在哪里按摩?
      • NO知道,对不起,我们公司1楼就有physio诊所,你进步来 :( chinatown和bells corners看见过有,没去过不好推荐。
    • 有现成程序,可以导出outlookexpress所有邮件
      • C++ source code? 挖,望码兴叹。谢谢anyway