Applescript: Save Selected Outlook Message as .eml File

為{幸葍}努か 提交于 2019-12-23 06:07:12

问题


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?


回答1:


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..




回答2:


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.



来源:https://stackoverflow.com/questions/16744001/applescript-save-selected-outlook-message-as-eml-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!