<?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; 办公自动化</title>
	<atom:link href="http://zhiqiang.org/blog/tag/%e5%8a%9e%e5%85%ac%e8%87%aa%e5%8a%a8%e5%8c%96/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>发送邮件的VBS脚本</title>
		<link>http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html</link>
		<comments>http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html#comments</comments>
		<pubDate>Sun, 12 Dec 2010 07:00:16 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[办公自动化]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/?p=1643</guid>
		<description><![CDATA[博客 » IT技术 » 办公自动化 » 系列：办公自动化 查看该系列所有文章 工作中或多或少有些琐碎的事情，比如每天要发送和接受数据，很多是通过邮件的方式传递的。之前写过如何在Outlook里自动保存附件，这里再发一个如何更方便地发送带附件的邮件。 主要是针对下面这个需求：每天需要发送一些特定的附件给特定的人，邮件有差不多固定格式的标题和正文，所带附件文件...]]></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>工作中或多或少有些琐碎的事情，比如每天要发送和接受数据，很多是通过邮件的方式传递的。之前写过<a href="http://zhiqiang.org/blog/it/auto-save-attachment-in-outlook.html">如何在Outlook里自动保存附件</a>，这里再发一个如何更方便地发送带附件的邮件。</p>
<p>主要是针对下面这个需求：每天需要发送一些特定的附件给特定的人，邮件有差不多固定格式的标题和正文，所带附件文件名的格式也比较固定，比如以当天日期为文件名的文件。</p>
<p>下载下面的vbs脚本随便放到某个地方，点击运行，将自动调用Outlook建立一封邮件（机器里需安装Office Outlook），自动填入预先指定的收件人，邮件标题为 "报告 2010-12-9"（后面日期可根据当天日期自动改变），并且载入D盘根目录下的"report 2010-12-9.docx"和"report 2010-12-9.pdf"作为附件。</p>
Note: There is a file embedded within this post, please visit this post to download the file.
<p>可对其进行自定义，用写字板打开这个vbs文件，修改下面这段即可：</p>
<pre>' receiptions 为收件人列表
' Subject 为邮件标题
' Body 为邮件正文
' Attachments 为附件列表，每个附件都需附带路径。
' autoSend 设置是否直接发送，设置为False时将停留在最后窗口，需手动按Outlook的发送按钮进行发送

receiptions = "math.zqy@gmail.com; blog@zhiqiang.org"
Subject = "报告 " &amp; sdt
Body = "附件是今日报告，请查收。"
Attachments = Array("D:\report " &amp; sdt &amp; ".docx", "D:\report " &amp; sdt &amp; ".pdf")
autoSend = False</pre>
<p>该脚本需要你使用Outlook作为邮件软件，上面的脚本在Outlook 2007下测试通过，但在别的版本下应该也能用的。对于Outlook Express和Lotus都能实现同样的东西，这里不阐述了。</p>
<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/auto-save-attachment-in-outlook.html">自动保存Outlook邮件的附件</a></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2010. | <a href="http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html#comments">1&#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/auto-send-email-with-vbs.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>动态修改Excel数据表的数据来源</title>
		<link>http://zhiqiang.org/blog/it/change-pivotcache-source.html</link>
		<comments>http://zhiqiang.org/blog/it/change-pivotcache-source.html#comments</comments>
		<pubDate>Wed, 13 Jan 2010 04:44:25 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[办公自动化]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[数据透视表]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/?p=1056</guid>
		<description><![CDATA[博客 » IT技术 » Excel » 系列：办公自动化 查看该系列所有文章 Excel有一个很有用的功能是直接导入外部数据库或者使用外部数据源建立数据透视表和数据透视图。但比较可惜的是，这个数据源的查询语句是静态的，它无法根据日期自动修改（比如在应用中，我们希望每天获取的外部数据都是当天最新的数据），下面两个函数是修改外部数据源的VBA代码，调用它们就可以建立...]]></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/excel'>Excel</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>Excel有一个很有用的功能是直接导入外部数据库或者使用外部数据源建立数据透视表和数据透视图。但比较可惜的是，这个数据源的查询语句是静态的，它无法根据日期自动修改（比如在应用中，我们希望每天获取的外部数据都是当天最新的数据），下面两个函数是修改外部数据源的VBA代码，调用它们就可以建立动态的数据源。</p>
<pre><span style="color: #008000;">' 更改数据表的来源</span>
<span style="color: #008000;">' wb：工作表对象</span>
<span style="color: #008000;">' connectionName：数据来源连接名称</span>
<span style="color: #008000;">' strSQL：新查询语句（修改SQL的查询代码）</span>
<span style="color: #008000;">' strSQLConnection：新连接语句（修改来源数据库，在对DBF数据库操作时非常有用）</span>
<span style="color: #008000;">' author: zhang@zhiqiang.org, 2010</span>
<span style="color: #0000ff;">Public</span> <span style="color: #0000ff;">Sub</span> ChangeODBCConnection(wb <span style="color: #0000ff;">As</span> Excel.Workbook, connectionName <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">String</span>, _
        <span style="color: #0000ff;">Optional</span> strSQL <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">String</span> = "", <span style="color: #0000ff;">Optional</span> strSQLConnection <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">String</span> = "")

    <span style="color: #0000ff;">With</span> wb.Connections(connectionName).ODBCConnection
        <span style="color: #0000ff;">If</span> Len(strSQLConnection) <span style="color: #0000ff;">Then</span> .CommandText = SplitString(strSQLConnection)
        <span style="color: #0000ff;">If</span> Len(strSQL) <span style="color: #0000ff;">Then</span> .Connection = SplitString(strSQL)
    <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">With</span>
    wb.Connections(connectionName).Refresh
<span style="color: #0000ff;">End</span> <span style="color: #0000ff;">Sub</span>

<span style="color: #008000;">' 更改数据表的来源</span>
<span style="color: #008000;">' pc：数据透视表的PivotCache对象 （例如：ActiveSheet.PivotTables(1).PivotCache）</span>
<span style="color: #008000;">' connectionName：数据来源连接名称</span>
<span style="color: #008000;">' strSQL：新查询语句（修改SQL的查询代码）</span>
<span style="color: #008000;">' strSQLConnection：新连接语句（修改来源数据库，在对DBF数据库操作时非常有用）</span>
<span style="color: #008000;">' author: zhang@zhiqiang.org, 2010</span>
<span style="color: #0000ff;">Public</span> <span style="color: #0000ff;">Sub</span> ChangePivotConnection(pc <span style="color: #0000ff;">As</span> Excel.PivotCache, <span style="color: #0000ff;">Optional</span> strSQLConnect, _
        <span style="color: #0000ff;">Optional</span> strSQL <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">String</span> = "")
    <span style="color: #0000ff;">Dim</span> blnODBCConnect <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">Boolean</span>

    <span style="color: #0000ff;">With</span> pc
        <span style="color: #0000ff;">If</span> .QueryType = xlODBCQuery <span style="color: #0000ff;">Then</span>
            blnODBCConnect = <span style="color: #0000ff;">True</span>
            <span style="color: #0000ff;">If</span> Len(strSQLConnect) = 0 <span style="color: #0000ff;">Then</span> strSQLConnect = .Connection
            strSQLConnect = Replace(strSQLConnect, "<span style="color: #8b0000;">ODBC;DSN</span>", "<span style="color: #8b0000;">OLEDB;DSN</span>", 1, 1, vbTextCompare)
        <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">If</span>

        <span style="color: #0000ff;">If</span> StrComp(.Connection, strSQLConnect, vbTextCompare) &lt;&gt; 0 <span style="color: #0000ff;">And</span> Len(strSQLConnect) <span style="color: #0000ff;">Then</span>
            .Connection = strSQLConnect
        <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">If</span>

        <span style="color: #0000ff;">If</span> StrComp(.CommandText, strSQL, vbTextCompare) &lt;&gt; 0 <span style="color: #0000ff;">And</span> Len(strSQL) <span style="color: #0000ff;">Then</span>
            .CommandText = (strSQL)
        <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">If</span>

        <span style="color: #0000ff;">If</span> blnODBCConnect = <span style="color: #0000ff;">True</span> <span style="color: #0000ff;">Then</span>
            .Connection = Replace(.Connection, "<span style="color: #8b0000;">OLEDB;DSN</span>", "<span style="color: #8b0000;">ODBC;DSN</span>", 1, 1, vbTextCompare)
        <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">If</span>

        .Refresh
    <span style="color: #0000ff;">End</span> <span style="color: #0000ff;">With</span>
<span style="color: #0000ff;">End</span> <span style="color: #0000ff;">Sub</span>

<span style="color: #008000;">' 将字符串分割成短字符串的数组</span>
<span style="color: #0000ff;">Private </span><span style="color: #0000ff;">Function</span> SplitString(<span style="color: #0000ff;">ByVal</span> s <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">String</span>) <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">Variant</span>
    <span style="color: #0000ff;">Dim</span> ss() <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">Variant</span>
    <span style="color: #0000ff;">Dim</span> i <span style="color: #0000ff;">As</span> <span style="color: #0000ff;">Long</span>

    <span style="color: #0000ff;">ReDim</span> ss(0 <span style="color: #0000ff;">To</span> Len(s) \ 200) <span style="color: #008000;">' note: it is not 256</span>
    <span style="color: #0000ff;">For</span> i = 0 <span style="color: #0000ff;">To</span> UBound(ss)
        ss(i) = Array(Mid(s, i * 200 + 1, 200))
    <span style="color: #0000ff;">Next</span> i

    SplitString = ss
<span style="color: #0000ff;">End</span> <span style="color: #0000ff;">Function</span></pre>
<p>以上代码在Office 2007版通过测试，其余版本未知。</p>
<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/auto-save-attachment-in-outlook.html">自动保存Outlook邮件的附件</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/to-get-gibberish-wordpress-move-to-dreamhost.html">搞定乱码，WordPress搬家到dreamhost</a></li><li><a href="http://zhiqiang.org/blog/it/speedup-blog-optimize-wordpress-database.html">加速blog：监测和优化WordPress数据库</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/database-query-is-np-hard.html">数据库查询是NP-Hard问题</a></li><li><a href="http://zhiqiang.org/blog/it/script-to-add-odbc-source.html">用脚本添加ODBC数据源</a></li><li><a href="http://zhiqiang.org/blog/it/use-adodb-in-matlab.html">Matlab中使用ADODB访问数据库</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/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>, 2010. | <a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html#comments">2 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/change-pivotcache-source.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>

