Немного расширив принятый ответ, мне потребовалась Delphi-реализация функции Сью set_account. Ничего не мог найти в интернете для этого, так что вот интерпретация Delphi кода Сью.
Function SetAccount(TargetAccount:string; var MailItem:OLEVariant):boolean;
var OLI,CBs,CBP,MC:olevariant;
strAccountBtnName:String;
i,t:Integer;
FoundAccount:Boolean;
Const ID_ACCOUNTS = 31224;
begin
FoundAccount:=false;
OLI:=MailItem.GetInspector;
CBs:=OLI.CommandBars;
CBP:=CBs.FindControl(, ID_ACCOUNTS);
t:=1;
while (not FoundAccount) and (t<=CBP.Controls.Count) do begin
MC:=CBP.Controls[t];
i:=Pos(' ',MC.Caption);
if i > 0 Then strAccountBtnName:=Copy(MC.Caption,i+1,Length(MC.Caption)-i)
else strAccountBtnName:=MC.Caption;
if strAccountBtnName = TargetAccount then begin
MC.Execute;
FoundAccount:=true;
end;
inc(t);
end;
Result:=FoundAccount;
end;
Благодарю Сью Мошер, спасибо, без тебя не обошлось бы :)