2014-06-26 32 views
0

由于FileMaker Pro不支持其创建的电子邮件的RTF/HTML格式,因此我创建了AppleScript来格式化电子邮件。有用!但它似乎只是格式化它在脚本中遇到的每个变量的第一个实例。任何指针都很乐意接受。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:"[email protected]_text.com"} 
    make new cc recipient at end of cc recipients with properties {address:"[email protected]_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 

回答

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" 
+0

看起来再简单不过可惜的AppleScript不属于它。第二例保持不变。 – bapple