我自动化展望和我需要控制谁的电子邮件出现。用户将有两个或更多账户的设立的前景和我需要可以选择哪些帐户发送的电子邮件。任何想法?

需要支持在展望2003年以上。我使用德尔菲2006年码本,但这并不真正的问题。

有帮助吗?

解决方案

一个人名叫苏Mosher写了一个漂亮的摘要在这个问题 microsoft。公众。办公室。开发。展望。vba.

总之,这归结为要么是这个:

  • 使用 MailItem.SentOnBehalfOfName, ,这只能在交换enviromnents(我想是您的情况)-当的用户有"发送"的权限的其他交流信箱的,这是很多同样的东西作为交换账户。
  • 使用一个小小的黑客,涉及到摆弄 CommandBars
  • 使用Outlook救赎
  • (在OL2007,你会 MailItem.SendUsingAccount)

其他提示

对接受的答案进行了扩展,我需要一个Delphi实现的Sue的set_account函数。无论如何都无法在互联网上找到任何东西,所以这里是对Sue代码的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;

归功于Sue Mosher,谢谢你,没有你就不可能做到:)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top