|
こんにちは、hi_sugarです。
hidesoft.4:03892| 鶴亀で各フォルダのメール数を確認するマクロについて
からの誘導です。
全アカウントに対して各フォルダにあるメール数リストアップし結果を新規
メールとして出力するマクロです。
//-----ここから-------------------------------------------------------
// メールカウントマクロ mailcount.mac by hi_sugar 2003/10/11
#indent = 2 ; // フォルダの階層間のインデント数
#fnmax = 40 ; // メール数の表示カラム
call Load_Tkinfo ;
call Check_Tkmain ;
#mwh = dllfunc("MainWnd");
$bname[0] = "受信" ;
$bname[1] = "未送信" ;
$bname[2] = "送信済み" ;
$bname[3] = "草稿" ;
$bname[4] = "ゴミ箱" ;
$bname[5] = "User" ;
#bname_num = 6 ;
#n = dllfunc( "DisableDraw",1 );
$cur_account = dllfuncstr("CurrentAccount") ;
$cur_folder = dllfuncstr("CurrentFolder") ;
if ( !dllfunc("NewMail") ) {
message "メールの作成に失敗しました";
goto TurukameEnd ;
}
#n = dllfunc("SetHeader", "Subject" , "Mail Count on "+
dllfuncstr("CurrentDate", "YYYY/MM/DD hh:mm") );
gofiletop;
beginsel;
gofileend ;
delete;
#aid = 0;
#totalall = 0 ;
while (1) {
$account = dllfuncstr( "ExecAt" , #mwh , "Account", #aid );
if ( $account == "" ) break ;
insert "●" + $account + "●\n" ;
#i = 0 ;
while ( #i < #bname_num ) {
#bname_cnt[#i] = 0 ;
$next_folder = $bname[#i] ;
$folder = $bname[#i] ;
#level = 0 ;
if ( ! dllfunc( "ExecAt",#mwh,"SelectFolder",$account,
$next_folder ) ) {
#i = #i + 1 ;
continue ;
}
while (1) {
#mcnt = dllfunc( "ExecAt",#mwh ,"GetFolderMailCount",
"", "", "all") ;
call Split_Line , $next_folder , "\\" ;
#level = ##return ;
call Space , (#level-1) * #indent ;
insert $word[#level - 1] ;
call Space , #fnmax - length($word[#level - 1]) -
(#level-1) * #indent ;
insert rightstr(" " + str(#mcnt) ,8) + "\n" ;
#bname_cnt[#i] = #bname_cnt[#i] + #mcnt ;
$next = dllfuncstr("ExecAt",#mwh,"GetNextFolder", "", "");
#x = strstr( $next, "\\");
if ( #x >= 0 ) {
$next_account = leftstr( $next, #x );
$next_folder = midstr( $next, #x + 1,
length($next) - #x - 1 );
} else {
$next_account = $next;
$next_folder = "";
}
if ( $account != $next_account || strstr( $next_folder ,
$bname[#i] ) != 0 ) {
break ;
}
if ( ! dllfunc( "ExecAt",#mwh,"SelectFolder",$account,
$next_folder ) ) {
break ;
}
}
#i = #i + 1 ;
}
call Space , #fnmax + 8 , "-" ;
insert "\n" ;
#j = 0 ;
#total = 0 ;
while ( #j < #bname_num ) {
insert $bname[#j] ;
call Space , #fnmax - length($bname[#j]) - 5 ;
insert "小計 " + rightstr(" " +
str(#bname_cnt[#j]) ,8) + "\n" ;
#total = #total + #bname_cnt[#j] ;
#j = #j + 1;
}
call Space , #fnmax - 5 ;
insert "合計 " + rightstr(" " + str(#total) ,8) + "\n\n" ;
#aid = #aid + 1 ;
#totalall = #totalall + #total ;
}
call Space , #fnmax + 8 , "=" ;
insert "\n" ;
call Space , #fnmax - 17 ;
insert "全アカウント総計 " + rightstr(" " +
str(#totalall) ,8) + "\n" ;
// 状況をリストア
#n = dllfunc("ExecAt",#mwh,"SelectFolder",$cur_account,$cur_folder );
#n = dllfunc("ExecAt" , #mwh , "EnableDraw" );
goto TurukameEnd ;
ERROR:
message "何らかのエラーによりマクロを中止します。";
TurukameEnd:
freedll ;
endmacro;
//===================================================================
// 共用サブルーチン
//===================================================================
//////////////////
// Load_Tkinfo //
//////////////////
// Tkinfo.dllのロード
Load_Tkinfo:
loaddll "tkinfo.dll";
if( ! result ) {
message "tkinfo.dll をロードできませんでした。";
freedll ;
endmacro ;
}
return ;
//////////////////
// Check_Tkmain //
//////////////////
// 本体ウィンドウ以外から実行なら終了
Check_Tkmain:
if ( !dllfunc("IsTuruKameMain") ) {
message "このマクロ(" + currentmacrobasename + ")は、\n" +
"鶴亀メール本体ウィンドウからしか起動できません。";
freedll ;
endmacro ;
}
return ;
////////////
// Space //
////////////
// 指定された数の文字(省略時は半角スペース)を繰り返し挿入
// パラメータ : ##1 スペース数
// : $$2 スペース数
Space:
##num = 0 ;
if ( $$2 == "" ) {
$$ch = " " ;
} else {
$$ch = $$2 ;
}
while ( ##num < ##1 ) {
insert $$ch ;
##num = ##num + 1 ;
}
return ;
//////////////////
// Split_Line //
//////////////////
// 改行までを読み取り、空白をデリミータとして単語に分割
// パラメータ : $$1 入力ストリング
// : $$2 セパレータ(省略時は半角スペース)
// 戻り : ##return 分割されたワード数
// $word[i] 分割されたワード
Split_Line:
##wnum = 0 ;
$word[0] = "" ; // グローバルリータン変数
if ( $$2 == "" ) {
$$sep = " " ;
} else {
$$sep = $$2 ;
}
$$s = $$1 ;
##sepl = strlen($$sep) ;
##chflg = 0 ;
while (1) {
##ptr = strstr($$s , $$sep) ;
if ( ##ptr >= 0 ) {
$word[##wnum] = leftstr($$s,##ptr) ;
##wnum = ##wnum + 1 ;
$$s = midstr($$s,##ptr + ##sepl, length($$s)
- ##ptr - ##sepl ) ;
} else {
break ;
}
}
$word[##wnum] = $$s ;
##wnum = ##wnum + 1 ;
return ##wnum ;
//-----ここまで-------------------------------------------------------
|
|