件名・宛先・添付ファイルなしの場合に警告を出す
次のルールをrules.xmlで指定してください。
<ruleSet folder="送信箱">
<rule match="@True()" use="active" description="To,Subjecの空白、添付ファイルなし、の警告">
<apply>@Progn(@If(@Not(To),@Set('a','- To\n'),1),@If(@Not(@Subject(@True(),@True())),@Set('a',@Concat($a,'- Subject\n')),1),@If(@Not(@Body()),@Set('a',@Concat($a,'- 本文\n')),1),@If(@And(@RegexMatch(@Body(),/添付|attached|attachment/i),@Not(@Attachment())),@Set('a',@Concat($a,'- 添付\n')),1),@If($a,@Progn(@Draft(@True()),@If(@Equal(6,@MessageBox(@Concat($a,'\nがないけど送信する?\n----------------------------------------\n はい(Y) - そのまま送信\n いいえ(N)- 再編集'),68)),@Draft(@False()),@InvokeAction('MessageCreate','edit','',@URI()))),@Exit()))</apply>
</rule>
</ruleSet>
下記の状況で警告を出すようにしました
- Toが空白のとき
- Subjectが空白のとき(Re:だけのときなども空白とみなす)
- 本文に「添付」「attached」「attachment」の単語があるにもかかわらず添付ファイルがないとき
警告が出たら?
- はい(Y)-そのまま送信する
- いいえ(N)-送信せず、メール編集画面に戻る
※ 下記のように4を68にすると警告音もでます
,@MessageBox(@Concat($a,' がないけど送信する?\n-------------------------\n はい(Y) - そのまま送信\n いいえ(N)- 再編集'),68))
指定ドメイン以外へのメール送付に警告を出す
次のルールをrule.xmlで指定してください。
<ruleSet folder="送信箱">
<rule match="@True()" use="active" description="To,Subjecの空白、添付ファイルなし、の警告">
<apply>@Progn(@Set('tgt',@If(@And(Cc,Bcc),@Concat(To,', ',Cc,', ',Bcc),@If(Cc,@Concat(To,', ',Cc),To))),@While($tgt,@Progn(@Set('mail',@If(@SubstringBefore($tgt,', '),@SubstringBefore($tgt,', '),$tgt)),@Set('tgt',@SubstringAfter($tgt,', ')),@If(@RegexMatch($mail,/@hogehoge\.com|@hogera/i),1,@Set('msg',@Concat($msg,'- ',$mail,'\n'))))),@If($msg,@Progn(@Draft(@True()),@If(@Equal(6,@MessageBox(@Concat($msg,'\nが指定外メールだけど送信する?\n----------------------------------------\n はい(Y) - そのまま送信\n いいえ(N)- 再編集'),68)),@Draft(@False()),@InvokeAction('MessageCreate','edit','',@URI()))),@Exit()))</apply>
</rule>
</ruleSet>
許可するドメイン、アドレスの一部を正規表現で指定します。
上記のマクロの @hogehoge\.com|@hogera の部分を変更します。この場合では
上記のマクロの @hogehoge\.com|@hogera の部分を変更します。この場合では
- @hogehoge.com
- @hogera
のどちらかを含むメール以外で警告を出します。
この部分を
この部分を
- @hogera\.com
とすればこのドメイン以外で警告を出します。.は\.とエスケープすることに注意してください。
返信メールの名前に自動で"様"を付ける
■reply.templateの中を下記に変更
元
元
To: {@If(@Exist('Reply-To'), Reply-To, From)}
変更後
To: {@Progn(@Set('to', @If(Reply-To, Reply-To, From)), @RegexReplace($to, /(?!様)("?) </, '様$1 <', :GLOBAL))}
■reply_all.templateを下記に変更(二箇所)
元
元
$from,
変更後
@Progn(@Set('to', @If(Reply-To, Reply-To, From)), @RegexReplace($to, /(?!様)("?) </, '様$1 <', :GLOBAL)),
元
@Concat('Cc: ', $val, '\n'),
変更後
@Progn(@Set('val1',@RegexReplace($val, /(?!様)("?) </, '様$1 <', :GLOBAL)),@Concat('Cc: ', $val1, '\n')),
BCCの付加をアカウント毎に する・しない を設定したい。
設定はQMAILを終了してから行うこと。
[変更点]
■account.xml Globalセクションに追加
[変更点]
■account.xml Globalセクションに追加
<key name="Bcc">1</key>
※ キーを作らなければBCCにならない。ならないようにキーを作る場合は値を0にする。
■reply_all.template、reply.template
@Equal(@Profile('', 'Global', 'Bcc', '1'), '0'), の前に下記を追加↓
■reply_all.template、reply.template
@Equal(@Profile('', 'Global', 'Bcc', '1'), '0'), の前に下記を追加↓
@Equal(@Profile(@Concat('accounts/', @Account(), '/account.xml'), 'Global', 'Bcc','0'), '1'),
@Concat('Bcc: ', @I(@Account(), X-QMAIL-SubAccount), '\n'),
■new.template、forward.template
@Set('bcc', @Equal(@Profile('', 'Global', 'Bcc', '1'), '1')), を下記に入れ替え↓
@Set('bcc', @Equal(@Profile('', 'Global', 'Bcc', '1'), '1')), を下記に入れ替え↓
@Set('bcc', @Or(@Equal(@Profile('', 'Global', 'Bcc', '1'), '1'),@Equal(@Profile(@Concat('accounts/', @Account(), '/account.xml'), 'Global', 'Bcc','0'), '1'))),
- QMAILの設定にあるBCC付加オプションはBCCつけないにしてから、上記を必要なACCOUNTに対してKeyを付け加えればオケ。 この設定法をする場合、「オプション」-「その他2」のBCC付加のチェックははずしておく。ここをチェックすると、すべてのアカウントでBCC付加になります。
新規メールを常に署名を記載した状態で開く
下記のマクロをnew.templateの最後に空行を付けないように付け加える。
{@Progn(
@Set('acct',@Account()),
@If(
@Equal($acct,'_hogera'),
@Set('sig','hogera <hogera@hoge.com>\nTEL 123456\nFAX 9876543'),
@Equal($acct,'hogu.co.jp'),
@Set('sig','hogu.co.jp\nHogera Hogu'),
@Set('sig','デフォルトの署名\nほげほげ')
),
@Concat('X-QMAIL-Signature: ','\n\n\n--\n',$sig)
)}
注意点
- このサンプルはサブアカウントは無視
- 上記でhogera、hogu.co.jpというのがアカウント名。hogeraというアカウントならhogera <hoge以下の署名、hogu.co.jpというアカウントなら、hogu.co.jp[改行]Hogera Hoguという署名、それ以外ならすべての新規メールでデフォルトの署名[改行]ほげほげ という署名を付加。\nは改行を意味します。
- わざわざX-QMAIL-Signature: というヘッダを付けているのは、オプションの設定で署名が付けられていたりした場合に強制的に「なし」の状態でエディット画面を開くようにするため。不要ならとってください。
- 返信や転送でも同じようにできます。@Load()を使って署名を一件ずつファイルにしてファイル名をアカウント名で保存しておき、それを読み込むなどすれば署名を変えたいときに多少便利かも。
返信時に名前を削除
$from,
'\n',
@If($val,
@Concat('Cc: ', $val, '\n'),
変更後)
@RegexReplace($from,/[^>,]+ </,'<',@True()),
'\n',
@If($val,
@Concat('Cc: ', @RegexReplace($val,/[^>,]+ </,'<',@True()), '\n'),
■reply.template
元)
元)
To: {@If(@Exist('Reply-To'), Reply-To, From)}
変更後)
To: {@If(@Exist('Reply-To'), @RegexReplace(Reply-To,/[^>,]+ </,'<',@True()), @RegexReplace(From,/[^>,]+ </,'<',@True()))}
送信者/宛先をアドレス帳にある名前で表示
表示→カラムのカスタマイズ→送信者/宛先
@If(@Sent(),@Concat('⇒ ',@FormatAddress(To,:FORMAT-NAME,:LOOKUP-FORCE)),@FormatAddress(From,:FORMAT-NAME,:LOOKUP-FORCE))
HTMLのタグを取るテンプレート
@Bodyを表示する部分を下記に変更
{@If(
@RegexMatch(@Body('',1), /<HTML/i),
@Progn(
@Set('x',@Body('',1)),
@While(
@RegexMatch($x,/<PRE>((?:.|\n)+?\n(?:.|\n)+?)<\/PRE>/i),
@Progn(
@Set('dum',$_1),
@Set('x',@RegexReplace($dum,/\n/,'<BR>',@True())),
@RegexReplace($x,/<PRE>((?:.|\n)+?\n(?:.|\n)+?)<\/PRE>/i,$dum),
)
),
@Set('x',@RegexReplace($x, /<DIV[^>]*>(?!\n)/i, '¶', @True())),
@Set('x',@RegexReplace($x, /<DIV[^>]*>/i, '', @True())),
@Set('x',@RegexReplace($x, /\n/, ' ', @True())),
@If(@RegexMatch($x,/<BODY/i),
@Progn(
@Set('x',@RegexReplace($x, /(.*<BODY.*?>)(.*)/i, '$2', @True())),
@Set('x',@RegexReplace($x, /(<\/BODY>.*)(<\/BODY>)/i, '$2', @True()))
),
@Set('x',@Concat($x,'\n</BODY></HTML>'))
),
@Set('x',@RegexReplace($x, /<BR>/i, '¶', @True())),
@Set('x',@RegexReplace($x, /(<P[^>]*margin-bottom:1[0-9][^>]*>(?:(?!<\/P>).)*<\/P>)/i, '$0¶', @True())),
@Set('x',@RegexReplace($x, /<P[^>]*class=mso[^>]*>/i, '¶', @True())),
@Set('x',@RegexReplace($x, /<P[^>]*>/i, '¶¶', @True())),
@Set('x',@RegexReplace($x, /\r|\n/, '', @True())),
@Set('x',@RegexReplace($x, /<HEAD>.*<\/HEAD>/i, '', @True())),
@Set('x',@RegexReplace($x, /<HR[^>]*>/i, '¶∬¶', @True())),
@Set('x',@RegexReplace($x, /<[^>]*>/, '', @True())),
@Set('x',@RegexReplace($x, /<|</, '<', @True())),
@Set('x',@RegexReplace($x, />|>/, '>', @True())),
@Set('x',@RegexReplace($x, /&|&/, '&', @True())),
@Set('x',@RegexReplace($x, /"|"/, '"', @True())),
@Set('x',@RegexReplace($x, / | /, ' ', @True())),
@Set('x',@RegexReplace($x, /’/, '\'', @True())),
@Set('x',@RegexReplace($x, /¶[\s|¶]+¶/, '¶¶', @True())),
@Set('x',@RegexReplace($x, /¶+∬¶+/, '\n\n----------------------------------------------------------------------\n', @True())),
@Set('x',@RegexReplace($x, /\s+¶/, '¶', @True())),
@Set('x',@RegexReplace($x, /¶¶¶+/, '¶¶', @True())),
@Set('x',@RegexReplace($x, /¶/, '\n', @True())),
@If(@RegexMatch($x, /&#\d{{2,6}};/),
@Set('x',@Script('result.value =arguments(0).replace(/&#(\\d{{2,6}})\;/g,function($0,$1){{return(String.fromCharCode($1));}})','JScript',$x)),
@True()
),
@Concat($x)
),
@Body(@Profile('', 'Global', 'Quote', '> '), 1)
)
}
HTMLメールをHTMLメールで返信する
下記を create_HTML全員返信.template という名前でTemplates\mail フォルダに保存。返信したいHTMLメールを右クリックしてテンプレートからHTML全員返信を選ぶ。
自分でHTML書く必要あります。
あと、引用した元メールのHTMLを大幅にダイエットします。
自分でHTML書く必要あります。
あと、引用した元メールのHTMLを大幅にダイエットします。
{@Catch(@Exist('From'), @Exit())}
{@Progn(@Set('val', @Progn(@Set('from', @If(@Exist('Reply-To'), Reply-To, From)), @Set('to', @Remove(To, @Address(@I(@Account(), X-QMAIL-SubAccount)), @Address($from))), @Set('cc', @Remove(Cc, @Address(@I(@Account(), X-QMAIL-SubAccount)), @Address($from))), @Concat($to, @If(@And($to, $cc), ', ', ''), $cc))), @Concat('To: ', $from, '\n', @If($val, @Concat('Cc: ', $val, '\n'), '')))}Subject: Re: {@Subject(@True(), @True())}
{@If(@Equal(@Profile('', 'Global', 'Bcc', '1'), '0'), '', @And(@Equal(@Profile('', 'Global', 'NoBccForML', '1'), '1'), @Or(@Exist('X-ML-Name'), @BeginWith(Subject, '['))), '', @Concat('Bcc: ', @I(@Account(), X-QMAIL-SubAccount), '\n'))}{@Progn(@Set('id', @MessageId()), @Set('ref', @References(4)), @Concat(@If($id, @Concat('In-Reply-To: ', $id, '\n'), ''), @If(@Or($ref, $id), @Concat('References: ', @If(@And($ref, $id), @Concat($ref, ' ', $id), $ref, $ref, $id), '\n'), '')))}X-QMAIL-Account: {@Account()}{@If(X-QMAIL-SubAccount, @Concat('\nX-QMAIL-SubAccount: ', X-QMAIL-SubAccount), '')}
X-QMAIL-Macro: @ForEach(@Messages('{@Concat('//', @Account(), '/', @Folder())}', {@Id()}), @Replied(@True()))
X-QMAIL-OriginalCharset: {@BodyCharset(1)}{@If(@Equal(@Profile('', 'Global', 'SaveSentInSameFolder', '0'), '1'), @Concat('\nX-QMAIL-Sentbox: ', @Folder()), '')}
Content-Type: text/html;charset={@If(@And(@Multipart(),@Catch(@If(@Part(0),@True(),@True()),@False())), @If( @RegexMatch(@Body('',2,@Part(0)),/<HTML|<P>|<\/DIV>|<\/FONT>/i), @Progn(@Set('Body',@Body('',2,@Part(0)),:GLOBAL),@BodyCharset(2,@Part(0))), @RegexMatch(@Body('',2,@Part(1)),/<HTML|<P>|<\/DIV>|<\/FONT>/i), @Progn(@Set('Body',@Body('',2,@Part(1)),:GLOBAL),@BodyCharset(2,@Part(1))), @RegexMatch(@Body('',2,@Part(1,@Part(0))),/<HTML|<P>|<\/DIV>|<\/FONT>/i), @Progn(@Set('Body',@Body('',2,@Part(1,@Part(0))),:GLOBAL),@BodyCharset(1,@Part(0))), @Progn(@Set('Body',@Body('',1,@Part(1)),:GLOBAL),@BodyCharset(1,@Part(1))), ), @Progn(@Set('Body',@Body('',1),:GLOBAL),@BodyCharset(1)))}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE></TITLE><STYLE><!--
BODY,P,PRE {{font-family:Arial}}
BLOCKQUOTE {{margin:0px;border-left:2px solid blue;padding:3pt}}
PRE {{font-size:100%}}<PRE>
ここに返信メールを書く。HTMLタグを書くときはpreタグ取ってください。
</PRE>
<P>----- Original Message -----<BR>
<B>From:</B> {@Name(From)}<BR>
<B>Sent:</B> {@Progn( @Set('x',@FormatDate(@Date(Date), '%W1, %M2 %D, %Y4 %h:%m %z', 2)), @Concat($x) )}<BR>
<B>To:</B> {@Name(To)}<BR>
{@If(@Exist('Cc'), @Concat('<B>Cc:</B> ',@Name(Cc),'<BR>\n'), '')}<B>Subject:</B> {Subject}
<P>
{@Progn(@Set('x',$Body), @Set('x',@RegexReplace($x, /^[-_=\.]+NextPart.*$/im, '', @True())), @Set('x',@RegexReplace($x, /^--------------\w+-+$/m, '', @True())), @While( @RegexMatch($x,/<PRE>((?:.|\n)+?\n(?:.|\n)+?)<\/PRE>/i), @Progn( @Set('dum',$_1), @Set('x',@RegexReplace($dum,/\n/,'<BR>',@True())), @RegexReplace($x,/<PRE>((?:.|\n)+?\n(?:.|\n)+?)<\/PRE>/i,$dum), ) ), @Set('x',@RegexReplace($x, /<DIV[^>]*>(?!\n)/i, '¶', @True())), @Set('x',@RegexReplace($x, /<DIV[^>]*>/i, '', @True())), @Set('x',@RegexReplace($x, /\n/, ' ', @True())), @If(@RegexMatch($x,/<BODY/i), @Progn( @Set('x',@RegexReplace($x, /(.*<BODY.*?>)(.*)/i, '$2', @True())), @Set('x',@RegexReplace($x, /(<\/BODY>.*)(<\/BODY>)/i, '$2', @True())) ), @Set('x',@Concat($x,'\n</BODY></HTML>')) ), @Set('x',@RegexReplace($x, /<BR>/i, '¶', @True())), @Set('x',@RegexReplace($x, /(<P[^>]*margin-bottom: *1[0-9][^>]*>(?:(?!<\/P>).)*<\/P>)/i, '$0¶', @True())), @Set('x',@RegexReplace($x, /<P[^>]*class=mso[^>]*>/i, '¶', @True())), @Set('x',@RegexReplace($x, /<P[^>]*>/i, '¶¶', @True())),
@Set('x',@RegexReplace($x, /<META[^>]*>/i, '', @True())), @Set('x',@RegexReplace($x, /<!--.*?-->/i, '', @True())), @Set('x',@RegexReplace($x, /<STYLE>(.*?)<\/STYLE>/i, '', @True())), @Set('x',@RegexReplace($x, /<\/DIV>|<P.*?>|<\/P>/i, '', @True())), @Set('x',@RegexReplace($x, /<FONT[^>]*>( | )*<\/FONT>/i, '', @True())), @Set('x',@RegexReplace($x, /<HR([^>]*)>/i, '<HR>', @True())), @Set('x',@RegexReplace($x, /<\?xml:[^>]+>/i, '', @True())), @Set('x',@RegexReplace($x, /style="[^"]+(COLOR:[^"]+")/i, 'style="$1', @True())), @Set('x',@RegexReplace($x, /(mso-|FONT-FAMILY:|FONT-SIZE:|FONT-WEIGHT:)[^>]+(["'])>/i, '$2>', @True())), @Set('x',@RegexReplace($x, / face="[^"]+"/i, '', @True())), @Set('x',@RegexReplace($x, / face=(,|\w)+/i, '', @True())), @Set('x',@RegexReplace($x, / size="?\d"?/i, '', @True())), @Set('x',@RegexReplace($x, / onclick=["'][^>]+["']/i, '', @True())), @Set('x',@RegexReplace($x, / (class|id|lang)=[\w\-"]+/i, '', @True())), @Set('x',@RegexReplace($x, / (src|background)="cid:[^>]*/i, '', @True())), @Set('x',@RegexReplace($x, / style=(""|'')/i, '', @True())), @Set('x',@RegexReplace($x, /(\s)+/, ' ', @True())), @Set('x',@RegexReplace($x, / >/, '>', @True())), @Set('x',@RegexReplace($x, /( | )+¶/, '¶', @True())), @Set('x',@Script(<<END function foo($x){{ $x=$x.replace(/<([a-zA-Z:]*)([^>]*)>(?:((?: | )*?)|(?:<([a-zA-Z:]*)([^>]*)>)((?: | )*?)(?:<\/\4>))<\/\1>/ig,''); $x=$x.replace(/<(FONT|SPAN)([^>]*)>([^<]*?)<\/\1><\1\2>([^<]*?)<\/\1>/ig,'<$1$2>$3$4<\/$1>'); $x=$x.replace(/<(FONT|SPAN)([^>]*)>([^<]*?)<\/\1><\1\2>([^<]*?)<\/\1>/ig,'<$1$2>$3$4<\/$1>'); $x=$x.replace(/<(FONT|SPAN)([^>]*)>([^<]*?)<\1\2>([^<]*?)<\/\1>([^<]*?)<\/\1>/ig,'<$1$2>$3$4$5<\/$1>');$x=$x.replace(/<(st1:[a-z\-]+)[^>]*>(.*?)<\/\1>/ig,'$2'); $x=$x.replace(/<(o:p)>(.*?)<\/\1>/ig,'$2'); $x=$x.replace(/<(FONT)>((?:(?!<\/?\1).)*)<\/\1>/ig,'$2'); $x=$x.replace(/<(SPAN)>((?:(?!<\/?\1).)*)<\/\1>/ig,'$2'); return $x; }} function foo1($x){{ $x=$x.replace(/¶ (<\/?[^>]*>)/ig,'¶$1'); return $x; }} $x = foo(arguments(0)); $x = foo($x); $x = foo($x); $x = foo1($x); result.value = $x;END,'JScript',$x)), @Set('x',@RegexReplace($x, /(\s| )+¶/, '¶', @True())), @Set('x',@RegexReplace($x, /¶¶¶+/, '¶¶', @True())), @Set('x',@RegexReplace($x, /^¶+/, '', @False())), @Set('x',@RegexReplace($x, /¶/, '<BR>\n', @True())), @Set('x',@RegexReplace($x, /<HR>(<BR>)*/i, '<HR>\n', @True())), @Set('x',@RegexReplace($x, /(<BLOCKQUOTE[^>]*>)(<BR>)+/i, '$1\n', @True())), @Set('x',@RegexReplace($x, /(<\/BLOCKQUOTE>)(<BR>)+/i, '$1\n', @True())), @Set('x',@Script(<<END function foo2($x){{ $n=$x.split(/\n/); str=''; dum=''; re=/^(<(FONT)([^>]+)>)(.*)(<\/FONT><BR>)$/i; for(key in $n){{ r=re.exec($n[key]); if(r !=null){{ if(dum==''){{ str+= RegExp.$1 + '\n' + RegExp.$4; dum=RegExp.$3; }}else if(dum!=RegExp.$3){{ str+='<\/FONT><BR>\n' + RegExp.$1 + '\n' + RegExp.$4 + RegExp.$5 +'\n'; dum=''; }}else{{ str+='<BR>\n' + RegExp.$4; dum=RegExp.$3; }} }}else{{ if(dum==''){{ str+=$n[key]+'\n'; }}else{{ str+='<\/FONT><BR>\n' + $n[key]+'\n'; }} dum=''; }} }} return str; }} function foo3(str){{ str=str.replace(/<BR>\n<BR>/ig,'\n<P>'); return str; }} $x = foo2(arguments(0)); $x = foo3($x); result.value = $x;END,'JScript',$x)), @If( @RegexMatch($x, /&#\d{{2,6}};/), @Set('x',@Script('result.value =arguments(0).replace(/&#(\\d{{2,6}})\;/g,function($0,$1){{return(String.fromCharCode($1));}})','JScript',$x)), @True() ), @Concat($x))
}
返信メールの引用をOE風にする
テンプレートの返信部分を下記に変更。
■元
■元
At {@FormatDate(@Date(Date), '%D %M1 %Y4 %h:%m:%s %z', 2)} {@Name(From)} wrote:
■変更後
----- Original Message ----- From: {@Name(From)} Sent: {@FormatDate(@Date(Date), '%W1, %M2 %D, %Y4 %h:%m %z', 2)} To: {@Name(To)} {@If(@Exist('Cc'), @Concat('Cc: ',@Name(Cc),'\n'), '')}Subject: {Subject}