Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Background:

Every work day I get an e-mail message from a known sender. The sender puts an attachment in the e-mail message. I have to process that attachment with a python script.

Question:

What is the best (automatic) way for me to get the attachment out of Outlook and onto my shell account (or local filesystem) so I can process it with the script, without having to manually open the file every day and save the attachment?

share|improve this question
    
I think it would be best not to handle this in the mail client, but on the mail server. (Like with Exim filters, if you happen to use that.) So, if that's an option, then please provide some details about that mail server, and about that shell account? –  Arjan Oct 10 '09 at 2:44

3 Answers 3

I assume you have an Exchange server that Outlook is talking to. Is IMAP enabled on the server? If so, it should be reasonably trivial to write a program that searches the IMAP server for an email from a particular sender received within the last 24 hours and parse out (what I assume to be) a MIME attachment.

share|improve this answer
    
That makes sense, I would have to write a script in whatever language has support for that kind of connection, powershell seems like a good fit. What would you choose? –  dreftymac Oct 10 '09 at 23:21
    
Personally, if I knew I was going to be using a Python script to parse the attachment, I'd just add a module to it that would start by opening the IMAP folder, finding the attachment, downloading it, then parsing it :) –  warren Oct 30 '09 at 4:54

I was researching the same thing and I found a script.

  1. You have to open outlook then press Alt + F11
  2. On the left pane expand Microsoft Outlook Objects
  3. Double click ThisOutlook Session
  4. Copy and paste this code:

    (Note: At "Const save_path As String = "c:\Temp\"" (replace "c:\Temp\" with the path to your file server. Remember to end path always with "\")

    Sub SaveToFolder(MyMail As MailItem)
    Dim strID As String
    Dim objNS As Outlook.NameSpace
    Dim objMail As Outlook.MailItem
    Dim objAtt As Outlook.Attachment
    Dim c As Integer
    Dim save_name As String
    'Place path to sav to on next line. Note that you must include the
    'final backslash
    Const save_path As String = "c:\Temp\"
    
    strID = MyMail.EntryID
    Set objNS = Application.GetNamespace("MAPI")
    Set objMail = objNS.GetItemFromID(strID)
    
    If objMail.Attachments.Count > 0 Then
    For c = 1 To objMail.Attachments.Count
    Set objAtt = objMail.Attachments(c)
    save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 5)
    save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
    save_name = save_name & Right(objAtt.FileName, 5)
    objAtt.SaveAsFile save_path & save_name
    
    Next
    End If
    
    Set objAtt = Nothing
    Set objMail = Nothing
    Set objNS = Nothing
    End Sub
    
  5. Go to Debug on menu and Compile...

  6. Close VB screen
  7. Go to rules and create a rule: when email is received from the person you mentioned in the distribution group, run a script (select script (your script will be listed)). I would add a notification with the rule so you know the rule ran as well rule to move email to a specific folder.
  8. Close and reopen Outlook.
share|improve this answer

Advanced ETL processor can automatically reply to emails, save attachments and process emails based on various rules

http://www.dbsoftlab.com/etl-tools/advanced-etl-pocessor-news/loading-excel-files-from-emails-questions-from-the-customer.html

share|improve this answer

protected by Community Jul 25 '13 at 15:26

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.