Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Applescript--osx邮件--如果段落以3位数字开头,则将一些单词加粗_Macos_Email_Formatting_Applescript - Fatal编程技术网

Macos Applescript--osx邮件--如果段落以3位数字开头,则将一些单词加粗

Macos Applescript--osx邮件--如果段落以3位数字开头,则将一些单词加粗,macos,email,formatting,applescript,Macos,Email,Formatting,Applescript,我有一个自动生成电子邮件的applescript。在此之前,脚本会查找以“Ep”开头的任何段落,并将该段落的前两个词加粗 但现在,电子邮件正文已经改变了。我们正在删除电子邮件正文中的“Ep”部分,因此我想将任何段落中以三位数开头的前两个单词加粗。我已经到处搜索过了,但我不知道如何让applescript查找以任何三位数开头的段落 以前的代码(基本上)是: 如有任何帮助,将不胜感激。请按以下方式修改脚本: tell application "Mail" activate

我有一个自动生成电子邮件的applescript。在此之前,脚本会查找以“Ep”开头的任何段落,并将该段落的前两个词加粗

但现在,电子邮件正文已经改变了。我们正在删除电子邮件正文中的“Ep”部分,因此我想将任何段落中以三位数开头的前两个单词加粗。我已经到处搜索过了,但我不知道如何让applescript查找以任何三位数开头的段落

以前的代码(基本上)是:


如有任何帮助,将不胜感激。

请按以下方式修改脚本:

tell application "Mail"
    activate
    
    set emailSubject to (" Daily Reports") as rich text
    set emailContent to ("123 some text 
724: some text
some random text
645Fgz: and more text")
    
    set theMessage to make new outgoing message with properties {visible:true, subject:emailSubject, content:emailContent}
    
    tell theMessage
        repeat with a_paragraph in paragraphs
            set lead_in to (characters 1 through 4 of a_paragraph) as rich text
            ignoring punctuation and hyphens
                considering numeric strings
                    if lead_in > 99 and lead_in < 1000 then
                        set font of (words 1 thru 2 of a_paragraph) to "Helvetica Bold"
                    end if
                end considering
            end ignoring
        end repeat
        make new to recipient at end of to recipients with properties {address:"test@example.com"}
    end tell
end tell
告诉应用程序“邮件”
激活
将emailSubject设置为富文本(“每日报告”)
将emailContent设置为“某些文本”
724:一些文本
一些随机文本
645Fgz:更多文本)
将消息设置为使用属性{visible:true,subject:emailSubject,content:emailContent}生成新的传出消息
告诉他们消息
在段落中重复一个或多个段落
将前导字符(段落的字符1到4)设置为富文本
忽略标点和连字符
考虑数字字符串
如果铅含量>99且铅含量<1000,则
将(段落中的单词1到2)的字体设置为“Helvetica粗体”
如果结束
结束考虑
结束忽略
结束重复
在结尾处向收件人添加新的收件人,并向具有属性{地址:}的收件人添加新的收件人test@example.com"}
结束语
结束语
当前三个字符是数字,第四个字符是字母、空格或标点符号时,这会更改段落中前两个单词的字体。它不会捕捉以0开头的数字(例如050)


请注意,如果您使用的是深色模式,出于某种原因,此脚本还会更改字体颜色。您可能需要解决这个问题。

谢谢!经过一点测试(和移动目标后),我注意到一行中的两个换行符将导致索引错误。最后,我在“设置潜在客户”行中添加了try/end try。工作完美。
tell application "Mail"
    activate
    
    set emailSubject to (" Daily Reports") as rich text
    set emailContent to ("123 some text 
724: some text
some random text
645Fgz: and more text")
    
    set theMessage to make new outgoing message with properties {visible:true, subject:emailSubject, content:emailContent}
    
    tell theMessage
        repeat with a_paragraph in paragraphs
            set lead_in to (characters 1 through 4 of a_paragraph) as rich text
            ignoring punctuation and hyphens
                considering numeric strings
                    if lead_in > 99 and lead_in < 1000 then
                        set font of (words 1 thru 2 of a_paragraph) to "Helvetica Bold"
                    end if
                end considering
            end ignoring
        end repeat
        make new to recipient at end of to recipients with properties {address:"test@example.com"}
    end tell
end tell