是否有一个脚本供hmailServer从传入的电子邮件中提取附件?

时间:2015-08-20 21:30:15

标签: vbscript email-attachments directory hmail-server

我有电子邮件进入我的hmail服务器。我需要编写接收电子邮件的规则/脚本(都有附件),并提取它们各自包含的文件。

如果您可以帮助我将这些提取的文件分类到我的D:/驱动器上的特定位置,那么

奖励积分!

2 个答案:

答案 0 :(得分:1)

您可以定义一个函数 SaveAttachments 并从 OnDeliverMessage 事件中调用

    Sub OnDeliverMessage(oMessage)
       call SaveAttachments(oMessage)
    End Sub

''''''''''''''''

    Sub SaveAttachments(oMessage)
    ' this routine saves file attachments that have the specified
    ' FileExtensions. 


      Dim SaveFolder   'where to store attachments. This folder must already exist. 
      SaveFolder = "c:\path_to_folder\"     ' trailing slash is required

      Dim SavedFile

      Dim FileExtensions ' set to the file attachment extensions you want to save
      FileExtensions = "(pdf|doc)"  

      Dim oAttachment    
      Dim oRegExp 
      Set oRegExp = new RegExp    
      For oAttachment = 0 to oMessage.Attachments.Count-1
      ' Test for specified attachments
       with oRegExp
        .Pattern = "^.*\."& FileExtensions & "$" 
        .IgnoreCase = True
        .Global = False
       end with
       if (oRegExp.test(oMessage.Attachments(oAttachment).Filename)) Then

         SavedFile = SaveFolder & Left(Right(oMessage.Filename,42),38) & "." & oAttachment & "." & oMessage.Attachments(oAttachment).Filename
         oMessage.Attachments(oAttachment).SaveAs(SavedFile)
         ' uncomment below to Delete Attachment from message
         'oMessage.Attachments(oAttachment).Delete
       End If 
      Next
      Set oRegExp = nothing

    End Sub

答案 1 :(得分:0)

对于可能的方法,首先:使用您选择的语言的IMAP,连接到想要的帐户,然后搜索imap正文解析代码,以提取到所需位置的附件。 第二种可能性是在EventHandler文件中的vbscript中使用服务器端脚本 你的工作是实现这个方法

        Sub OnDeliverMessage(oMessage)
Enter code Here

    '   End Sub