美文网首页
重要的邮件需要自动保存下来O(∩_∩)O

重要的邮件需要自动保存下来O(∩_∩)O

作者: 白天才痴 | 来源:发表于2016-02-26 17:10 被阅读156次

    在outlook中按ALT+F11打开VBA编辑器,插入下述代码:

    Public Sub SaveAttach(Item As Outlook.MailItem)
        
        'SaveAttachment Item, "D:\\", "*.png" '
        'MsgBox Item.Body
        Dim a, b  As String
        a = Format(Date, "yyyy-m-d")   '当前年月日
        b = Format(Time, "-hh-mm")     '当前时间
        Dim sFile As Object, FSO As Object
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set sFile = FSO.CreateTextFile("d:\\WWW\\IMEBuild\\Build-" + a + b + ".html", True)
        sFile.WriteLine (Item.Body)
        sFile.Close
        Set sFile = Nothing
        Set FSO = Nothing
    End Sub
    ' 保存附件
    ' path为保存路径,condition为附件名匹配条件
    Private Sub SaveAttachment(ByVal Item As Object, path$, Optional condition$ = "*")
        Dim olAtt As Attachment
        Dim i As Integer
        If Item.Attachments.Count > 0 Then
            For i = 1 To Item.Attachments.Count
                Set olAtt = Item.Attachments(i)
                ' save the attachment
                If olAtt.FileName Like condition Then
                    olAtt.SaveAsFile path & olAtt.FileName
                End If
            Next
        End If
        Set olAtt = Nothing
    End Sub
    
    

    添加完保存后
    新建规则,比如组内同学要把哆啦A梦的截图保存到指定位置,可以如下设置


    指定发件人,下一步选择运行脚本

    点击脚本选择

    确定后,点击完成,下次发送截图邮件就可以直接保存到文件夹下了
    #######如果规则没生效
    Outlook的信任中心勾选上“允许使用脚本”。
    对于Outlook 2007,在“工具->信任中心->电子邮件安全性->文件夹中的脚本",勾选上"允许在公用文件夹中使用脚本"和"允许在共享文件夹中使用脚本"
    对于Outlook 2010,相应选项位于“文件->选项->信任中心->电子邮件安全性"里。

    相关文章

      网友评论

          本文标题:重要的邮件需要自动保存下来O(∩_∩)O

          本文链接:https://www.haomeiwen.com/subject/eqiikttx.html