Copy link to clipboard
Copied
I want to export an email template (.elm file) for Microsoft Outlook every time I compose a new email using Apple Script in InDesign script. I use the script as below, but it does not work 😞
var script = [
'tell application "Microsoft Outlook"',
"set theMessage to the first message in drafts",
"tell me to saveMsg(theMessage)",
"end tell",
"to saveMsg(theMsg)",
'set folderPath to ("Users:userName:Downloads:")',
'if (do shell script "/bin/test -e " & quoted form of (POSIX path of folderPath) & " ; echo $?") is "1" then',
'do shell script "/bin/mkdir -p " & quoted form of (POSIX path of folderPath)',
"end if",
'set timeStamp to do shell script "date +%Y%m%d%H%M%S"',
'set emailSubject to "Test"',
'set fileName to emailSubject & "_" & timeStamp',
'set savePath to folderPath & fileName & ".eml" as string',
"save theMsg in file (savePath)",
"end saveMsg",
].join("\r");
app.doScript(
script,
ScriptLanguage.APPLESCRIPT_LANGUAGE,
undefined,
UndoModes.ENTIRE_SCRIPT,
undefined
)
Does any expert help me? I got stuck in it for around 3 hours :(((
Thank you in advance!
Hi all, I solved this issue by not using the function in the Applescript string saveMsg(theMsg) as below. Thank you all for spending your time on my case.
var script = [
'tell application "Microsoft Outlook"',
"set theMessage to the first message in drafts",
'set folderPath to ("Users:userName:Downloads:")',
'if (do shell script "/bin/test -e " & quoted form of (POSIX path of folderPath) & " ; echo $?") is "1" then',
'do shell script "/bin/mkdir -p " & quoted form of (POSIX path
...
Copy link to clipboard
Copied
Hi,
In what way does it not work?
Do you have a message in your drafts folder? if not you might want to change the first line to
set theMessage to make new outgoing message
Copy link to clipboard
Copied
Hi all, I solved this issue by not using the function in the Applescript string saveMsg(theMsg) as below. Thank you all for spending your time on my case.
var script = [
'tell application "Microsoft Outlook"',
"set theMessage to the first message in drafts",
'set folderPath to ("Users:userName:Downloads:")',
'if (do shell script "/bin/test -e " & quoted form of (POSIX path of folderPath) & " ; echo $?") is "1" then',
'do shell script "/bin/mkdir -p " & quoted form of (POSIX path of folderPath)',
"end if",
'set timeStamp to do shell script "date +%Y%m%d%H%M%S"',
'set emailSubject to "Test"',
'set fileName to emailSubject & "_" & timeStamp',
'set savePath to folderPath & fileName & ".eml" as string',
"save theMsg in file (savePath)",
"end tell"
].join("\r");