Foxmailのを呼び出すために電子メールを送ります

そこにはFoxmailのAPIコールインターフェース、仕事ではありませんし、Foxmailの(主にアクセサリー)を使用してメールを送信する必要があるため。オンラインは、この点には手順が見つかりませんでした。クローズアップ自分自身を書くために例を見て

例としては、次のとおりです:

  私たちは、System.Runtime.InteropServicesを使用して追加する必要があります。

    パブリッククラスFoxmailHelper
    {
        [DLLIMPORT( "user32.dllの"、エントリーポイント= "のFindWindow")]
        プライベートのexternのIntPtrのFindWindow(ストリングlpClassName、列lpWindowName)静的。

        [DLLIMPORT( "user32.dllの"、エントリーポイント= "は、GetWindow")]
        プライベートのextern静的のIntPtrは、GetWindow(のIntPtrのhWnd、UINT NCMD)。

        [DLLIMPORT( "user32.dllの")]
        静的にextern int型getClassNameメソッド(のIntPtr hWndは、StringBuilderのlpClassName、INT nMaxCount)。


        [DLLIMPORT( "User32.dllの"、項目CharSet = CharSet.Auto)]
        パブリック静的にextern int型GetWindowText(のIntPtr hWndは、StringBuilderのテキスト、INT nMaxCount)。

        [DLLIMPORT( "user32.dllの"、エントリーポイント= "FindWindowEx"、
        パブリック静的にexternのIntPtr FindWindowEx(のIntPtr hwndParent、のIntPtr hwndChildAfter、ストリングlpszClass、列lpszWindow)。

        [DLLIMPORT( "user32.dllの"、エントリーポイント= "SendMessageA")]
        プライベート静的にextern int型のSendMessage(HWNDのIntPtr、INT WMSG、のIntPtr wParamに、ストリングのlParam);

        const int型WM_SETTEXT = 0x0Cの。

        /// <要約>
        ///
        /// </要約>
        /// <PARAM NAME = "と">收件人</ PARAM>
        /// <PARAM NAME = "CC">抄送</ PARAM >
        /// <PARAM NAME = "BCC">密送</ PARAM>
        /// <PARAM NAME = "被験者">主题</ PARAM>
        /// <PARAM NAME = "listAttrach">附件<


        パブリック静的ブール(文字列に対して、文字列CC、文字列BCC、ストリング対象、リストの<string> listAttrach、ストリング含有量= "")を送信
        {
           System.Diagnostics.Process []プロセス= System.Diagnostics.Process.GetProcesses()。

            文字列foxMailFilePath = "";

            //找到Foxmailの的文件路径
            foreachの(プロセスでSystem.Diagnostics.ProcessのP)
            {
                (p.ProcessName.Equals( "Foxmailの"、StringComparison.OrdinalIgnoreCase))であれば
                {
                    foxMailFilePath = p.MainModule.FileName。
                    ブレーク;
                }
            }
            文字列(もし。

                ( "Foxmailの未启动或未安装!")新しい例外を投げます。
            }
          
            文字列は「」=取り付けます。
            文字列subjectText = "";

            (!listAttrach = null)の場合は
            {
                listAttrach.ForEach(S =>
                {
                    ; "{S} "+ = $添付する
                    subjectText + = $"{System.IO.Path.GetFileNameWithoutExtension(S)}、";
                });
                添付= attach.Trim(」「);
                subjectText = subjectText.Trim( '')。





                CreateNoWindow = TRUE、
                RedirectStandardError =真、
                RedirectStandardInput =真、
                RedirectStandardOutput = TRUE
            ;}
            (もし!string.IsNullOrEmpty(添付))
            {
                processStartInfo.Argumentsの=は添付;
            }
            他
            {
                processStartInfo.Arguments = $ "のmailto:{へ}?BCC = {BCC}&CC = {CC}&被写体= {件名}&体= {内容}";
            }
            BOOL ISOK = FALSE;
            プロセスプロセス=新しいプロセス(){StartInfo = processStartInfo}。
            ISOK = process.Start()。
            System.Threading.Thread.Sleep(1000);


            StringBuilderのSB =新しいStringBuilderの();
            StringBuilderのsbtext =新しいStringBuilderの();

            IntPtr foxForm =のFindWindow(NULL、$ "{subjectText} -写邮件")。//主窗体TFoxComposeForm.UnicodeClass
            getClassNameメソッド(foxForm、SB、256);
 
            IntPtr foxFrame =は、GetWindow(foxForm、5)。//TFoxComposeFrame.UnicodeClass
            getClassNameメソッド(foxFrame、SB、256)。
 
            IntPtrのlayoutManager =は、GetWindow(foxFrame、5)。// TLayoutManager
            getClassNameメソッド(のlayoutManager、SB、256);
   
            //取得第一个子控件
            のIntPtr Webオーサリングツールは、GetWindow =(のlayoutManager、5)。// TFoxHTMLEditor
            getClassNameメソッド(Webオーサリングツール、SB、256);

            //のBcc(次)
            のIntPtr = bccEditerは、GetWindow(Webオーサリングツール、2);
            getClassNameメソッド(bccEditer、SB、256);
            のSendMessage(bccEditer、WM_SETTEXT、IntPtr.Zero、BCC);

            / / CC(次)
            のIntPtr = ccEditerは、GetWindow(bccEditer、2);
            getClassNameメソッド(ccEditer、SB、256);
            のSendMessage(ccEditer、WM_SETTEXT、IntPtr.Zero、CC);

            //(次へ)
            のIntPtr toEditer GetWindow =(ccEditer、2);
            getClassNameメソッド(toEditer、SB、256);
            // GetWindowText(toIntPtr、sbtext、256);
            のSendMessage(toEditer、WM_SETTEXT、IntPtr.Zero、へ);


            //テーマ
            IntPtr subjectEditer = FindWindowEx(のlayoutManager、IntPtr.Zero、 "TFMEdit.UnicodeClass"、NULL);
            getClassNameメソッド(subjectEditer、SB、256)。
            SendMessage(subjectEditer、WM_SETTEXT、IntPtr.Zero、被写体);


            ISOKを返します。
        }

    }

おすすめ

転載: www.cnblogs.com/liyiqi12/p/11353658.html