简体   繁体   English

AppleScript邮件格式

[英]AppleScript mail formatting

Because FileMaker Pro doesn't support RTF/HTML formatting of the emails it creates I have created an AppleScript to format the email. 因为FileMaker Pro不支持它创建的电子邮件的RTF / HTML格式,所以我创建了一个AppleScript来格式化电子邮件。 It works! 有用! However it only seems to format the first instance of each variable it encounters in the script. 但是,它似乎只能格式化它在脚本中遇到的每个变量的第一个实例。 Any pointers gladly accepted. 任何指针都欣然接受。

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

I think the easiest way to solve is defining 2 new variables for the second instances of field_b and field_c : 我认为最简单的解决方法是为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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM