How to get outlook email attachment onto a file server?
Solution 1
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.
Solution 2
I was researching the same thing and I found a script.
- You have to open outlook then press Alt + F11
- On the left pane expand Microsoft Outlook Objects
- Double click ThisOutlook Session
-
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
Go to Debug on menu and Compile...
- Close VB screen
- 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.
- Close and reopen Outlook.
Solution 3
Advanced ETL processor can automatically reply to emails, save attachments and process emails based on various rules
Related videos on Youtube
Comments
-
dreftymac over 1 year
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?
-
Arjan over 14 yearsI 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?
-
-
dreftymac over 14 yearsThat 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?
-
David Yates over 14 yearsPersonally, 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 :)