Outlook中实现Gmail中的存档功能

时间管理中有重要的一条,保持你的收件箱整洁、干净。Gmail一个重要的创新就是Archive(存档),选中邮件后点下“archive”按钮或者按一下快捷键y,邮件就被移出收件箱,但又跟删除邮件不一样,这些邮件还可以继续被搜索。这里讲最近写的如何在Outlook里实现这个功能。

效果:按快捷键ALT+Y或者点击工具栏上的“存档”按钮,选中的邮件自动转移到事先设定好的存档文件夹内。

image

实现方法:

1. 在收件箱下建立存档文件夹,文件夹名为“存档”。

2. 核心工具是macro(宏),具体讲是一段vba代码。按ALT+F11,打开VBA编辑器,展开左侧的Project1,输入下列代码:

Sub ArchiveEmail()
    Dim destFolder As Outlook.folder
    Dim sel As Outlook.Selection, item As Outlook.MailItem
    Set destFolder = Outlook.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("存档")
    Set sel = Application.ActiveExplorer.Selection

    For Each item In sel
        item.Move destFolder
    Next item
End Sub

3. 接下来我们要做的两个事情,设置快捷键和在工具栏上放置按钮。不同于Excel中可以给自定义宏设置快捷键,Outlook无法直接给自定义宏设置快捷键,只有通过将宏放在工具栏上来间接实现。

  • Outlook主界面的工具栏上点右键 –> 自定义 –> 重排命令,选择常用工具栏
  • 点击添加,选中“宏”中的Project1-ThisOutlookSession-ArchiveEmail后确定。
  • 将刚才添加的宏上移或者下移到喜欢的位置,我把它放在“删除(D)”的下面。
  • 点右侧的更改所选内容,将其命名改为“存档(&Y)”,还可以给按钮选一个比较好看的按钮图像,我选的是笑脸符号。

 

以上在Office 2007+Win XP上试验通过。

  • 自动保存Outlook邮件的附件 在工作中定期或不定期会收到一些数据文件,然后要将它们的附件保存到自己的电脑上,下面演示如何让Outlook自动做这件事情。 首先,下面的SaveAttach...
  • 李笑来的时间管理系列文章 这两天看到了李笑来(老师)写的关于时间管理的系列文章,如获珍宝,读后收获很大,特此写一篇blog推荐之。 时间管理,这玩意儿都是说起来容...
  • 动态修改Excel数据表的数据来源 Excel有一个很有用的功能是直接导入外部数据库或者使用外部数据源建立数据透视表和数据透视图。但比较可惜的是,这个数据源的查询语句是静态的...
11条留言 -> 跳到留言表格
  • At 2009.11.22 23:01, Sunny said:

    你可真是 VBA 高手啊

    • At 2009.11.23 09:18, Franky Alex said:

      请教您个问题,我在gmail中的邮件存档后,如何还原他们,我找不到他们了

      • At 2009.11.23 20:43, zhiqiang said:

        ... 到All Mail文件夹里去找,在草稿文件夹的下面那个文件夹。

        或者直接搜索

    • At 2009.11.22 23:06, Tribieal said:

      很实用的VBA,OUTlook自己的存档太笨了,谢谢。

      • At 2009.11.23 21:57, wilderwein said:

        成天捣鼓那些玩意,不疼老婆

        • At 2009.12.11 01:33, honglet said:

          Hi there,

          Thanks for the illustration of this vba script. however, it seems to me that this can not be operated on a selection of more than 250 (or 255) items. Any thoughts on this? Thanks!

          • At 2009.12.11 08:43, zhiqiang said:

            I couldn't test the problem you reported since I didn't have enough emails now :-D

            I think the problem could be solved as following: For selections with lots of items, just use the "Move to " functionality provided by outlook itself: use keyboard shortcut "CTRL+SHIFT+V" then choose a fold.

            And the script in the post is used for selections with few items which happen in most times.

          • At 2009.12.11 20:10, honglet said:

            en.. I wrote a script for saving the email in text. It seems to me there is no such functionality in outlook.

            • At 2010.01.14 18:48, cozi said:

              如果我想把存档文件夹放在我的个人文件夹下面,怎么样才可以找到这个文件夹呢?
              比如文件夹结构如下:
              -- Mailbox
              -- Inbox
              -- Outbox
              -- Personal Folders
              -- Archieve

              我尝试过 ... .GetDefaultFolder(olFolderInbox).Parent().Folders("Achieve") 不过不对...

              应该继续自己去找答案的,只是之前没怎么接触过VB, 效率有些低,就想偷懒问问这个问题怎么解决?
              如果方便再顺便推荐一下如果想继续学习这方面的话,看哪些资料比较系统和有效。

              • At 2010.01.15 10:47, zhiqiang said:

                把Parent()的括号去掉即可:

                GetDefaultFolder(olFolderInbox).Parent.Folders("Achieve")
                

                或者利用目录结构

                Folders("个人文件夹").Folders("Achieve")
                

                我一般都是直接看Outlook的帮助文档来做这些事情。微软在架构设置和帮助文档上做的很不错,已经足够用了,再遇到搞不定的就去网上搜。

                • At 2010.01.15 16:14, cozi said:

                  多谢~ ^_^

                  试了一下,两种方法都可行。
                  也谢谢关于学习资料的推荐~

              (Required)
              (Required, not published)

                B | I | U | D | 添加链接 | 插入引用 | 插入代码 | 插入表情 | | + | ?
              guest | 注册 | BBS | 管理 | English | 繁體 | https

              阅微堂

              zhiqiang's personal blog
              Loading...
              Loading...
              Loading...