• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
5

Create an elm file for new Outlook email

Explorer ,
Sep 11, 2023 Sep 11, 2023

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!

TOPICS
Experiment , How to , Scripting

Views

153

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Sep 19, 2023 Sep 19, 2023

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

Votes

Translate

Translate
Community Expert ,
Sep 15, 2023 Sep 15, 2023

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

LATEST

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");

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines