Outlook中实现Gmail中的存档功能
时间管理中有重要的一条,保持你的收件箱整洁、干净。Gmail一个重要的创新就是Archive(存档),选中邮件后点下“archive”按钮或者按一下快捷键y,邮件就被移出收件箱,但又跟删除邮件不一样,这些邮件还可以继续被搜索。这里讲最近写的如何在Outlook里实现这个功能。
效果:按快捷键ALT+Y或者点击工具栏上的“存档”按钮,选中的邮件自动转移到事先设定好的存档文件夹内。
实现方法:
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上试验通过。
你可真是 VBA 高手啊
请教您个问题,我在gmail中的邮件存档后,如何还原他们,我找不到他们了
... 到All Mail文件夹里去找,在草稿文件夹的下面那个文件夹。
或者直接搜索
很实用的VBA,OUTlook自己的存档太笨了,谢谢。
成天捣鼓那些玩意,不疼老婆
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!
I couldn't test the problem you reported since I didn't have enough emails now
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.
en.. I wrote a script for saving the email in text. It seems to me there is no such functionality in outlook.
如果我想把存档文件夹放在我的个人文件夹下面,怎么样才可以找到这个文件夹呢?
比如文件夹结构如下:
-- Mailbox
-- Inbox
-- Outbox
-- Personal Folders
-- Archieve
我尝试过 ... .GetDefaultFolder(olFolderInbox).Parent().Folders("Achieve") 不过不对...
应该继续自己去找答案的,只是之前没怎么接触过VB, 效率有些低,就想偷懒问问这个问题怎么解决?
如果方便再顺便推荐一下如果想继续学习这方面的话,看哪些资料比较系统和有效。
把Parent()的括号去掉即可:
GetDefaultFolder(olFolderInbox).Parent.Folders("Achieve")或者利用目录结构
Folders("个人文件夹").Folders("Achieve")我一般都是直接看Outlook的帮助文档来做这些事情。微软在架构设置和帮助文档上做的很不错,已经足够用了,再遇到搞不定的就去网上搜。
多谢~ ^_^
试了一下,两种方法都可行。
也谢谢关于学习资料的推荐~