6

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 bob@whysendmereportsbyemail.com sends an email with the subject "Activity Report for YYYY-MM-DD" to me at john@myemailaddress.com

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.

4

2 回答 2

3

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.

于 2010-01-09T20:24:45.783 回答
0

我终于编写了代码来存储来自 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
于 2011-03-04T05:43:23.723 回答