AppleScript邮件格式化

时间:2014-06-26 00:53:36

标签: macos applescript filemaker

由于FileMaker Pro不支持其创建的电子邮件的RTF / HTML格式,因此我创建了AppleScript来格式化电子邮件。有用!但是,它似乎只是格式化它在脚本中遇到的每个变量的第一个实例。任何指针都乐意接受。

tell application "FileMaker Pro"
set field_a to cell "Email::emailText_1" of layout "Email"
set field_b to cell "Email::emailText_2" of layout "Email"
set field_c to cell "Email::emailText_3" of layout "Email"
set field_d to cell "Email::emailText_4" of layout "Email"
set field_e to cell "Email::emailText_5" of layout "Email"
set field_f to cell "Email::emailText_6" of layout "Email"
set field_g to cell "Email::emailText_7" of layout "Email"
set theAttachment to cell "Email::attachmentPath_cleaned"
end tell

set the_content to (field_a & field_b & field_c & " ?? " & field_d & field_e & field_f & field_b & field_g & " ?? " & field_c)

tell application "Mail"
activate
set theSignature to "signature 1"
set msg to make new outgoing message with properties {visible:true, subject:field_a & " text here " & startDate & " to " & endDate, content:the_content}
set message signature of msg to signature theSignature
tell msg
    make new to recipient at end of to recipients with properties {address:"blurred_out@blurry_text.com"}
    make new cc recipient at end of cc recipients with properties {address:"blurred_out@blurry_text.com"}
    make new attachment with properties {file name:theAttachment as alias}

    set x to offset of field_b in the_content
    set font of characters (x - 1) thru (x + (count of field_b)) of content to "Helvetica Bold"

    set x to offset of field_d in the_content
    set font of characters (x - 1) thru (x + (count of field_d)) of content to "Helvetica Bold"

    set x to offset of field_f in the_content
    set font of characters (x - 1) thru (x + (count of field_f)) of content to "Helvetica Bold"

    set x to offset of field_g in the_content
    set font of characters (x - 1) thru (x + (count of field_g)) of content to "Helvetica Bold"

    set x to offset of "??" in the_content
    set font of characters (x - 1) thru (x + (count of "??")) of content to "Helvetica Bold"
end tell
end tell

1 个答案:

答案 0 :(得分:0)

我认为最简单的解决方法是为field_bfield_c的第二个实例定义2个新变量:

set field_b1 to cell "Email::emailText_2" of layout "Email"
set field_c1 to cell "Email::emailText_3" of layout "Email"

set the_content to (field_a & field_b & field_c & " ?? " & field_d & field_e & field_f & field_b1 & field_g & " ?? " & field_c1)

set x to offset of field_b1 in the_content
set font of characters (x - 1) thru (x + (count of field_b1)) of content to "Helvetica Bold"

set x to offset of field_c1 in the_content
set font of characters (x - 1) thru (x + (count of field_c1)) of content to "Helvetica Bold"
相关问题