<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; outlook</title>
	<atom:link href="http://zhiqiang.org/blog/tag/outlook/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>zhiqiang&#039;s personal blog</description>
	<lastBuildDate>Wed, 08 Sep 2010 04:07:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>自动保存Outlook邮件的附件</title>
		<link>http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html</link>
		<comments>http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html#comments</comments>
		<pubDate>Wed, 09 Dec 2009 21:30:00 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[办公自动化]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/?p=970</guid>
		<description><![CDATA[在工作中定期或不定期会收到一些数据文件，然后要将它们的附件保存到自己的电脑上，下面演示如何让Outlook自动做这件事情。
首先，下面的SaveAttach函数可以保存附件中的docx文档到D盘根目录下。用ALT+F11打开VBA编辑器，插入下述代码：
Public Sub SaveAttach(Item As Outlook.MailItem)
    SaveAttachment Item, &#34;D:\&#34;, &#34;*.docx&#34;
    ' MsgBox &#34;附件已保存&#34;
End Sub

' 保存附件
' path为保存路...]]></description>
			<content:encoded><![CDATA[<p>在工作中定期或不定期会收到一些数据文件，然后要将它们的附件保存到自己的电脑上，下面演示如何让Outlook自动做这件事情。</p>
<p>首先，下面的SaveAttach函数可以保存附件中的docx文档到D盘根目录下。用ALT+F11打开VBA编辑器，插入下述代码：</p>
<pre><span style="color: #0000ff">Public</span> <span style="color: #0000ff">Sub</span> SaveAttach(Item <span style="color: #0000ff">As</span> Outlook.MailItem)
    SaveAttachment Item, &quot;<span style="color: #8b0000">D:\&quot;, </span>&quot;*.docx&quot;
    <span style="color: #008000">' MsgBox &quot;附件已保存&quot;</span>
<span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span>

<span style="color: #008000">' 保存附件</span>
<span style="color: #008000">' path为保存路径，condition为附件名匹配条件</span>
<span style="color: #0000ff">Private</span> <span style="color: #0000ff">Sub</span> SaveAttachment(<span style="color: #0000ff">ByVal</span> Item <span style="color: #0000ff">As</span> <span style="color: #0000ff">Object</span>, path$, <span style="color: #0000ff">Optional</span> condition$ = &quot;<span style="color: #8b0000">*</span>&quot;)
    <span style="color: #0000ff">Dim</span> olAtt <span style="color: #0000ff">As</span> Attachment
    <span style="color: #0000ff">Dim</span> i <span style="color: #0000ff">As</span> <span style="color: #0000ff">Integer</span>

    <span style="color: #0000ff">If</span> Item.Attachments.Count &gt; 0 <span style="color: #0000ff">Then</span>
        <span style="color: #0000ff">For</span> i = 1 <span style="color: #0000ff">To</span> Item.Attachments.Count
            <span style="color: #0000ff">Set</span> olAtt = Item.Attachments(i)
            <span style="color: #008000">' save the attachment</span>
            <span style="color: #0000ff">If</span> olAtt.FileName <span style="color: #0000ff">Like</span> condition <span style="color: #0000ff">Then</span>
                olAtt.SaveAsFile path &amp; olAtt.FileName
            <span style="color: #0000ff">End</span> <span style="color: #0000ff">If</span>
        <span style="color: #0000ff">Next</span>
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">If</span>
    <span style="color: #0000ff">Set</span> olAtt = <span style="color: #0000ff">Nothing</span>
<span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span></pre>
<p>如何实现自动保存呢？利用Office Outlook 2007的规则，它可以设定对满足一定条件的邮件自动运行脚本，然后选择脚本为SaveAttach函数即可。这样便能实现收到某些邮件时自动保存符合条件的附件到相应文件目录。</p>
<div><h2>相关文章</h2><ul><li><a href="http://zhiqiang.org/blog/it/archive-email-in-outlook.html">Outlook中实现Gmail中的存档功能</a> <small>时间管理中有重要的一条，保持你的收件箱整洁、干净。Gmail一个重要的创新就是Archive（存档），选中邮件后点下“archive”按钮或者按一下快捷键y，...</small></li><li><a href="http://zhiqiang.org/blog/it/add-help-for-user-defined-function.html">为Excel自定义函数添加帮助信息</a> <small>函数列表界面显示选中函数的说明信息  效果图：   实现方式：  Application.MacroOptions(Macro:=&quot;UDFtest&quot...</small></li><li><a href="http://zhiqiang.org/blog/it/refer-excel-worksheet-in-vba.html">VBA中引用WorkSheet的新方法</a> <small>最近学到一招，效果不错～

在写VBA中常需要引用某个WorkSheet对象，一般通过工作表名
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet2Name")
或...</small></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a> <small>Excel有一个很有用的功能是直接导入外部数据库或者使用外部数据源建立数据透视表和数据透视图。但比较可惜的是，这个数据源的查询语句是静态的...</small></li><li><a href="http://zhiqiang.org/blog/it/accessor-is-not-a-parameter-accessor-error.html">Oracle：存取器不是参数存取器或列值被截断</a> <small>最近写一个vba程序的时候不间歇的出现 “存取器不是参数存取器 ”或者“列值被截断”的错误。后来发现对于我等不专业人士，遇到这样的错误还挺e...</small></li><li><a href="http://zhiqiang.org/blog/it/match-date-in-vba.html">VBA中的Date类型的匹配问题</a> <small>VBA的Date类型比较奇怪。  测试：  1. 新建一个空白的Excel文档，在A1单元格输入2009-11-12。  2. 打开VBA编辑器，插入模块，增加下面这个宏  Sub test()
    MsgBo...</small></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2009. | <a href="http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html#comments">5 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Outlook中实现Gmail中的存档功能</title>
		<link>http://zhiqiang.org/blog/it/archive-email-in-outlook.html</link>
		<comments>http://zhiqiang.org/blog/it/archive-email-in-outlook.html#comments</comments>
		<pubDate>Sun, 22 Nov 2009 05:26:41 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[办公自动化]]></category>
		<category><![CDATA[时间管理]]></category>

		<guid isPermaLink="false">http://yueweitang.org/blog/?p=953</guid>
		<description><![CDATA[时间管理中有重要的一条，保持你的收件箱整洁、干净。Gmail一个重要的创新就是Archive（存档），选中邮件后点下“archive”按钮或者按一下快捷键y，邮件就被移出收件箱，但又跟删除邮件不一样，这些邮件还可以继续被搜索。这里讲最近写的如何在Outlook里实现这个功能。
效果：按快捷键ALT+Y或者点击工具栏上的“存档”按钮，选中的邮件自动转移到事先设定好的存档文件夹...]]></description>
			<content:encoded><![CDATA[<p>时间管理中有重要的一条，<strong>保持你的收件箱整洁、干净</strong>。Gmail一个重要的创新就是Archive（存档），选中邮件后点下“archive”按钮或者按一下快捷键y，邮件就被移出收件箱，但又跟删除邮件不一样，这些邮件还可以继续被搜索。这里讲最近写的如何在Outlook里实现这个功能。</p>
<p>效果：按快捷键ALT+Y或者点击工具栏上的“存档”按钮，选中的邮件自动转移到事先设定好的存档文件夹内。</p>
<p><a href="http://zhiqiang.org/blog/wp-content/uploads/OutlookGmail_BC1A/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="31" alt="image" src="http://zhiqiang.org/blog/wp-content/uploads/OutlookGmail_BC1A/image_thumb.png" width="664" border="0" /></a> </p>
<p>实现方法：</p>
<p>1. 在收件箱下建立存档文件夹，文件夹名为“存档”。</p>
<p>2. 核心工具是macro(宏)，具体讲是一段vba代码。按ALT+F11，打开VBA编辑器，展开左侧的Project1，输入下列代码：</p>
<pre><span style="color: #0000ff">Sub</span> ArchiveEmail()
    <span style="color: #0000ff">Dim</span> destFolder <span style="color: #0000ff">As</span> Outlook.folder
    <span style="color: #0000ff">Dim</span> sel <span style="color: #0000ff">As</span> Outlook.Selection, item <span style="color: #0000ff">As</span> Outlook.MailItem
    <span style="color: #0000ff">Set</span> destFolder = Outlook.Application.GetNamespace(&quot;<span style="color: #8b0000">MAPI</span>&quot;).GetDefaultFolder(olFolderInbox).Folders(&quot;<span style="color: #8b0000">存档</span>&quot;)
    <span style="color: #0000ff">Set</span> sel = Application.ActiveExplorer.Selection

    <span style="color: #0000ff">For</span> <span style="color: #0000ff">Each</span> item <span style="color: #0000ff">In</span> sel
        item.Move destFolder
    <span style="color: #0000ff">Next</span> item
<span style="color: #0000ff">End</span> <span style="color: #0000ff">Sub</span></pre>
<p>3. 接下来我们要做的两个事情，设置快捷键和在工具栏上放置按钮。不同于Excel中可以给自定义宏设置快捷键，Outlook无法直接给自定义宏设置快捷键，只有通过将宏放在工具栏上来间接实现。</p>
<ul>
<li>Outlook主界面的工具栏上点右键 –&gt; 自定义 –&gt; 重排命令，选择常用工具栏 </li>
<li>点击添加，选中“宏”中的Project1-ThisOutlookSession-ArchiveEmail后确定。 </li>
<li>将刚才添加的宏上移或者下移到喜欢的位置，我把它放在“删除(D)”的下面。 </li>
<li>点右侧的更改所选内容，将其命名改为“存档(&amp;Y)”，还可以给按钮选一个比较好看的按钮图像，我选的是笑脸符号。 </li>
</ul>
<p>&#160;</p>
<p>以上在Office 2007+Win XP上试验通过。</p>
<div><h2>相关文章</h2><ul><li><a href="http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html">自动保存Outlook邮件的附件</a> <small>在工作中定期或不定期会收到一些数据文件，然后要将它们的附件保存到自己的电脑上，下面演示如何让Outlook自动做这件事情。  首先，下面的SaveAttach...</small></li><li><a href="http://zhiqiang.org/blog/resource/xiao-time-to-the-management-of-a-series-of-articles.html">李笑来的时间管理系列文章</a> <small>这两天看到了李笑来（老师）写的关于时间管理的系列文章，如获珍宝，读后收获很大，特此写一篇blog推荐之。

时间管理，这玩意儿都是说起来容...</small></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a> <small>Excel有一个很有用的功能是直接导入外部数据库或者使用外部数据源建立数据透视表和数据透视图。但比较可惜的是，这个数据源的查询语句是静态的...</small></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2009. | <a href="http://zhiqiang.org/blog/it/archive-email-in-outlook.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/archive-email-in-outlook.html#comments">11 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/archive-email-in-outlook.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
