user2419057
user2419057

Reputation: 3

Applescript: Save Selected Outlook Message as .eml File

Looking for some guidelines or tips on how to save a selected Outlook mail message as a .eml file on my Mac.

Is there an easy command for this or do I have to actually write the file using the contents from the selected message?

Upvotes: 0

Views: 2935

Answers (2)

Darrick Herwehe
Darrick Herwehe

Reputation: 3722

If you're just trying to save one at a time and not batch, you can just drag it to the Finder and it will create an .eml file automatically.

Upvotes: -1

markhunte
markhunte

Reputation: 6932

Hi this is an extract from a script I use.

You just have to save the email to a file.

It saves the message as a text file. The reason I do this is I can then Search the text file better with spotlight.

If I open the text file in TextEdit I see the raw email. Not very readable. But I can actually drag it onto the Outlook icon in the Dock and it will open as a normal outlook email.

  set folderPath to ((path to home folder from user domain as string) & "MS_Emails") --PATH TO YOU FOLDER
--TEST IF FOLDER EXISTS. IF NOT CREATE IT
if (do shell script "/bin/test -e " & quoted form of (POSIX path of folderPath) & " ; echo $?") is "1" then
    -- 1 is false
    do shell script "/bin/mkdir -p " & quoted form of (POSIX path of folderPath)

end if

tell application "Microsoft Outlook"
    -- GET SELECTE EMAILS
    set messages_ to the selection

    --ITERATE THROUGH THEM AND SAVE THEM
    repeat with i from 1 to number of items in messages_
        set theMsg to item i of messages_
        set textPath to folderPath & "email.txt" as string
        save theMsg in (textPath)

    end repeat
end tell

If you change the extension to .eml instead of txt. Your default email app will open it when you double click on the file. In my case that will be Mail.app but yours maybe Outlook.

Neither will have a problem reading the file

You can use various methods to set a unique name to each file..

Upvotes: 4

Related Questions