以编程方式处理新电子邮件和存储附件的最佳方法是什么

发布于 2024-08-17 04:32:23 字数 802 浏览 13 评论 0原文

我有几个客户/供应商通过电子邮件向我分发报告。其中一些文件非常巨大,需要从电子邮件中删除并保存在文件共享上进行处理,以及控制邮箱大小。

任何人都可以提供有关自动下载和保存附件的推荐方法的指导吗?

我处于 MS Windows 环境(客户端和服务器计算机)中。电子邮件位于 Microsoft Exchange 2003 电子邮件服务器上。

优先使用 Microsoft 技术以实现解决方案之间的一致性 (C#),但是我愿意接受任何建议,无论是 C#、VBScript、Perl、Java、我应该购买的组件等

。 每天 [email protected] 会发送一封主题为“Activ”的电子邮件政府报告YYYY-MM-DD”给我 [email protected]

每封电子邮件都有一个名为“ActivityReport-YYYY-MM”的附件-DD-HH-MI-SS.xls”我需要将其保存在我的文件系统上 “C:\FilesFromBob\ActivityReport-YYYY-MM-DD-HH-MI-SS.xls”

提前感谢您的帮助。

I have several clients/vendors that distribute reports to me via email. Some of these files are enormous, and need to be removed from email and saved on a file share for processing, as well as to control mailbox size.

Can anyone provide guidance on their recommended method of automatically downloading and saving attachments.

I am in a MS Windows Environment (Client & Server Computers). Emails are on an Microsoft Exchange 2003 Email Server.

Preferred use of Microsoft Technology for consistency across solutions (C#), however I am open to any suggestions, be it C#, VBScript, Perl, Java, Components I should purchase, etc..

Scenario
Each Day [email protected] sends an email with the subject "Activity Report for YYYY-MM-DD" to me at
[email protected]

Each Email has an attachment named "ActivityReport-YYYY-MM-DD-HH-MI-SS.xls" which I need to save on my filesystem at
"C:\FilesFromBob\ActivityReport-YYYY-MM-DD-HH-MI-SS.xls"

Thanks in advance for any assistance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖风昔人 2024-08-24 04:32:23

Exchange 2003 提供了一个WebDav API,您可以使用它从用户帐户访问电子邮件、联系人等。

SO 上已经有一些关于访问用户的 Exchange 收件箱的答案。我之前已经将这种方法用于几乎完全符合您概述的情况,一旦您制定出 WebDav API 模型以及请求和响应的结构,提取电子邮件及其附件就不会太困难。

还有其他与 Exchange 2003 交互的方法(此处概述),但我只尝试过 WebDav 方法,因为它似乎是最可靠的。

Exchange 2003 provides a WebDav API which you can use to access emails, contacts etc.. from a user's account.

There's a few answers about accessing a user's Exchange inbox on SO already. I've previously used this approach for almost exactly the situation you outline, and once you work out the WebDav API model and the structure of the requests and responses, it's not too difficult to extract emails and their attachments.

There are other ways to interact with Exchange 2003 (outlined on SO here), but I've only tried the WebDav approach because it seemed the most reliable.

伏妖词 2024-08-24 04:32:23

我终于编写了存储来自 Outlook 的邮件的代码
不幸的是,此代码在 Outlook 中运行,因此 Outlook 必须打开。

我还没有研究如何安排跑步,但现在很容易做到

Sub SaveOutlookFileAttachments()


Dim oStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oFolders As Outlook.Folders
Dim oFolder As Outlook.Folder
Dim destFolder As String
Dim oItems As Outlook.Items
Dim oMsg As Outlook.MailItem
Dim oAttachments As Outlook.Attachments
Dim oAttachment As Outlook.Attachment
Dim oExplorer As Outlook.Explorer


destFolder = "\\NetworkShare\OrderDetailReport\"

On Error Resume Next
Set oStores = Application.Session.Stores

For Each oStore In oStores
    If oStore.DisplayName = "Inbox" Then
        oFolders = oStore.GetSearchFolders
        For Each oFolder In oFolders
        oItems = oFolder.Items
            For Each oMsg In oItems
                oAttachments = oMsg.Attachments
                For Each oAttachment In oAttachments
                    If InStr(1, oAttachment.FileName, "orderdetail_", vbTextCompare) Then
                        'MsgBox ("This File Needs to be Saved: " & oAttachment.FileName)
                        oAttachment.SaveAsFile (destFolder & oAtch.DisplayName)
                    End If
                Next
            Next

        Next

    End If

Next


End Sub

I finally wrote the code to store messages from Outlook
Unfortunately this code runs from within Outlook, so Outlook has to be open.

I did not yet investigate how to schedule the run, but now its easy to do

Sub SaveOutlookFileAttachments()


Dim oStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oFolders As Outlook.Folders
Dim oFolder As Outlook.Folder
Dim destFolder As String
Dim oItems As Outlook.Items
Dim oMsg As Outlook.MailItem
Dim oAttachments As Outlook.Attachments
Dim oAttachment As Outlook.Attachment
Dim oExplorer As Outlook.Explorer


destFolder = "\\NetworkShare\OrderDetailReport\"

On Error Resume Next
Set oStores = Application.Session.Stores

For Each oStore In oStores
    If oStore.DisplayName = "Inbox" Then
        oFolders = oStore.GetSearchFolders
        For Each oFolder In oFolders
        oItems = oFolder.Items
            For Each oMsg In oItems
                oAttachments = oMsg.Attachments
                For Each oAttachment In oAttachments
                    If InStr(1, oAttachment.FileName, "orderdetail_", vbTextCompare) Then
                        'MsgBox ("This File Needs to be Saved: " & oAttachment.FileName)
                        oAttachment.SaveAsFile (destFolder & oAtch.DisplayName)
                    End If
                Next
            Next

        Next

    End If

Next


End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文