<?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>理工科背景的证券从业人员</description>
	<lastBuildDate>Sun, 05 Feb 2012 03:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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[博客 » IT技术 » VBA » 系列：办公自动化 查看该系列所有文章 在工作中定期或不定期会收到一些数据文件，然后要将它们的附件保存到自己的电脑上，下面演示如何让Outlook自动做这件事情。 首先，下面的SaveAttach函数可以保存附件中的docx文档到D盘根目录下。用ALT+F11打开VBA编辑器，插入下述代码： Public Sub SaveAttach(Item As Outlook.MailItem) SaveAttachment Item, "D:\", "*.docx" ' MsgBox "附件已...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/it">IT技术</a> » <a href='http://zhiqiang.org/blog/tag/vba'>VBA</a>  » </p><div class="series"><span>系列：<b>办公自动化</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e5%8a%9e%e5%85%ac%e8%87%aa%e5%8a%a8%e5%8c%96">查看该系列所有文章</a>
<div id='series'></div>
</div>  <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, "<span style="color: #8b0000;">D:\", </span>"*.docx"
    <span style="color: #008000;">' MsgBox "附件已保存"</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$ = "<span style="color: #8b0000;">*</span>")
    <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>
<p>补充：如果上面方法没效果，可以尝试修改下面的设置（由wfustc在留言中指出）</p>
<blockquote><p>在Outlook的信任中心勾选上“允许使用脚本”。</p>
<p>对于Outlook 2007，在“工具-&gt;信任中心-&gt;电子邮件安全性-&gt;文件夹中的脚本"，勾选上"允许在公用文件夹中使用脚本"和"允许在共享文件夹中使用脚本"</p>
<p>对于Outlook 2010，相应选项位于“文件-&gt;选项-&gt;信任中心-&gt;电子邮件安全性"里。</p></blockquote>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/it/archive-email-in-outlook.html">Outlook中实现Gmail中的存档功能</a></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a></li><li><a href="http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html">发送邮件的VBS脚本</a></li><li><a href="http://zhiqiang.org/blog/it/accessor-is-not-a-parameter-accessor-error.html">Oracle：存取器不是参数存取器或列值被截断</a></li><li><a href="http://zhiqiang.org/blog/it/match-date-in-vba.html">VBA中的Date类型的匹配问题</a></li><li><a href="http://zhiqiang.org/blog/it/add-help-for-user-defined-function.html">为Excel自定义函数添加帮助信息</a></li><li><a href="http://zhiqiang.org/blog/it/refer-excel-worksheet-in-vba.html">VBA中引用WorkSheet的新方法</a></li><li><a href="http://zhiqiang.org/blog/it/debug-excel-vba.html">调试Excel VBA代码</a></li><li><a href="http://zhiqiang.org/blog/it/unusual-byref-behavior-excel-vba.html">不正常的Excel VBA函数参数处理现象</a></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">21 &#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>21</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[博客 » IT技术 » 办公自动化 » 系列：办公自动化 查看该系列所有文章 时间管理中有重要的一条，保持你的收件箱整洁、干净。Gmail一个重要的创新就是Archive（存档），选中邮件后点下“archive”按钮或者按一下快捷键y，邮件就被移出收件箱，但又跟删除邮件不一样，这些邮件还可以继续被搜索。这里讲最近写的如何在Outlook里实现这个功能。 效果：按快捷键ALT+Y或者点击工具...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/it">IT技术</a> » <a href='http://zhiqiang.org/blog/tag/%e5%8a%9e%e5%85%ac%e8%87%aa%e5%8a%a8%e5%8c%96'>办公自动化</a>  » </p><div class="series"><span>系列：<b>办公自动化</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e5%8a%9e%e5%85%ac%e8%87%aa%e5%8a%a8%e5%8c%96">查看该系列所有文章</a>
<div id='series'></div>
</div>  <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 style="display: inline; border-width: 0px;" title="image" src="http://zhiqiang.org/blog/wp-content/uploads/OutlookGmail_BC1A/image_thumb.png" border="0" alt="image" width="664" height="31" /></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("<span style="color: #8b0000;">MAPI</span>").GetDefaultFolder(olFolderInbox).Folders("<span style="color: #8b0000;">存档</span>")
    <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>以上在Office 2007+Win XP上试验通过。</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html">自动保存Outlook邮件的附件</a></li><li><a href="http://zhiqiang.org/blog/resource/xiao-time-to-the-management-of-a-series-of-articles.html">李笑来的时间管理系列文章</a></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a></li><li><a href="http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html">发送邮件的VBS脚本</a></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">12 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/archive-email-in-outlook.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

