dotnetbbs

检查OutLook收件箱

Private Sub Application_NewMail()


\'Written by Lee Mason
\'Platform: Outlook VBA
\'Purpose: Checks inbox for read mail and (in this case) moves it to
\'an folder. Also counts unread mail in mailbox.

------------------

On Error goto 1000

\'Declares and initialised variables
Dim myOlApp As Application
Dim myNameSpace As NameSpace
Dim myibox As MAPIFolder
Dim mydelitems As MAPIFolder
Dim myitem As MailItem
Dim n As Integer
Dim unreadmail As Integer

n = 1
unreadmail = 0
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myibox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set mymovefolder = myibox.Folders("Old Items")

\'Looks at items in the inbox and moves to
\'Inbox/Old Items Folder if read, otherwise adds to the
\'running count of unread items.

For n = 1 To myibox.Items.Count
    Set myitem = myibox.Items(n)
    If myitem.UnRead = True Then
        unreadmail = unreadmail + 1
    Else: myitem.Move mymovefolder
   
    End If
Next n

1000 msgbox err.name
发表于 2006-03-25 13:18  RogerWang  阅读(328)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-12-17
  • 2021-05-07
  • 2022-01-21
  • 2022-02-10
  • 2021-12-31
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-22
  • 2021-11-13
  • 2021-09-09
  • 2022-02-07
  • 2021-12-10
  • 2021-06-04
  • 2022-12-23
相关资源
相似解决方案