【问题标题】:How to create an event e-mail using AppleScript and a text file?如何使用 AppleScript 和文本文件创建事件电子邮件?
【发布时间】:2013-11-28 12:18:42
【问题描述】:

我必须使用文本文件作为模板来创建 Outlook 电子邮件。我看过一些脚本,但没有像我需要的那样。在创建电子邮件之前,我还需要编辑文件的一些内容。我还需要知道放置该模板文件的最佳位置。

有一个用于创建新电子邮件的脚本,但我不知道如何从这里加载测试和编辑。

更新代码----

    --read source from the file

set theFile to "/Users/eclit/Desktop/MeetingTemplate.html"
open for access theFile
set fileContents to (read theFile)
close access theFile

tell application "Microsoft Outlook"

    set newMessage to make new outgoing message with properties {subject:"Hooray for automation", content:fileContents & return & return}
    make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
    open newMessage
end tell

请帮忙。

【问题讨论】:

  • 您使用的是哪个版本的 Mac OS X?是否可以选择 Apple Mail 而不是 Outlook?
  • 您的代码来自this StackOverflow post。我建议您要么发布what have you tried,要么在careers section 中聘请众多有才华的开发人员之一
  • @adayzdone 嗯,这将是脚本。我正在使用 Mavericks 和 Outlook 11
  • 现在我可以读取文件并生成电子邮件,但我仍然需要用其他字符串替换一些字符串

标签: outlook applescript outlook-addin osx-mavericks


【解决方案1】:
    --read source from the file

set theFile to "/Users/eclit/Desktop/MeetingTemplate.html"
open for access theFile
set fileContents to (read theFile)
close access theFile

on replaceText(find, replace, subject)
    set prevTIDs to text item delimiters of AppleScript
    set text item delimiters of AppleScript to find
    set subject to text items of subject

    set text item delimiters of AppleScript to replace
    set subject to "" & subject
    set text item delimiters of AppleScript to prevTIDs

    return subject
end replaceText

-- log fileContents

on categoryForName(_categoryName)
    tell application "Microsoft Outlook"
        try
            return category _categoryName
        on error
            try
                -- Getting by name doesn't always work.
                repeat with _category in categories
                    if _category's name is _categoryName then return _category
                end repeat
            end try
            make new category with properties {name:_categoryName}
        end try
        return category _categoryName
    end tell
end categoryForName

log fileContents

tell application "Microsoft Outlook"
    --set newMessage to make new outgoing message with properties {subject:"Hooray for automation", content:fileContents & return & return}
    set theCategory to my categoryForName("Work")
    --set theCategory to make new category with properties {name:"Fanciful", color:{12345, 23456, 11111}}
    set newEvent to make new calendar event with properties {subject:"Dial In : +442034333797  Conference code: 5270687926", content:fileContents}
    --make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
    --open newMessage
    open newEvent
end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 2022-09-25
    • 2014-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多