1

3 つの異なる部門のメールボックス (それぞれ独自のメール サーバーと nsf ファイルを使用) から (domino.dll を使用して) メールを送信できるプログラムを作成しています。3 つの部門のすべてのメールボックスには、次のような定義済みのメール署名があります。

よろしく部門X

これらはいつでも変更できるため、プログラムで署名をハードコーディングしたくありませんが、代わりにメールボックス/nsf ファイルから抽出し、メール本文に追加します (または、より良い方法がある場合は別のもの)。

私はこの問題の解決策を見つけることなく一日中見回していたので、私の質問は次のとおりです:これはどのように達成されますか?

これまでのところ、私のコードは次のようになります。

public Boolean sendNotesMail(String messageText)
    {
        //Create new notes session 
        NotesSession _notesSession = new NotesSession();
        //Initialize Notes Database to null; 
        NotesDatabase _notesDataBase = null;
        //Initialize Notes Document to null; 
        NotesDocument _notesDocument = null;

        string mailServer = @"Path/DDB";
        string mailFile = @"Deparmentmail\number.nsf";

        //required for send, since its byRef and not byVal, gets set later. 
        object oItemValue = null;

        // Start the connection to Notes. Otherwise log the error and return false
        try
        {
            //Initialize Notes Session 
            _notesSession.Initialize("");
        }
        catch
        {
           //Log
        }

        // Set database from the mailServer and mailFile
        _notesDataBase = _notesSession.GetDatabase(mailServer, mailFile, false);

        //If the database is not already open then open it. 
        if (!_notesDataBase.IsOpen)
        {
            _notesDataBase.Open();
        }

        //Create the notes document 
        _notesDocument = _notesDataBase.CreateDocument();

        //Set document type 
        _notesDocument.ReplaceItemValue("Form", "Memo");

        //sent notes memo fields (To and Subject) 
        _notesDocument.ReplaceItemValue("SendTo", emailAddress);
        _notesDocument.ReplaceItemValue("Subject", subjectText);
        // Needed in order to send from a departmental mailbox
        _notesDocument.ReplaceItemValue("Principal", _notesDataBase.Title);

        //Set the body of the email. This allows you to use the appendtext 
        NotesRichTextItem _richTextItem = _notesDocument.CreateRichTextItem("Body");

        // Insert the text to the body 
        _richTextItem.AppendText(messageText);
        try
        {
            _notesDocument.Send(false, ref oItemValue);
        }

}

編集: Richard Schwartz のおかげで、私の解決策は次のとおりです。

object signature = _notesDataBase.GetProfileDocument("calendarprofile", "").GetItemValue("Signature");
String[] stringArray = ((IEnumerable)signature).Cast<object>().Select(x => x.ToString()).ToArray();
_richTextItem.AppendText(stringArray[0]);
4

2 に答える 2

3

署名は、NSF ファイルのプロファイル ドキュメントに保存されます。メソッドNotesDatabase.getProfileDocument()を使用してアクセスできます。このメソッドは、次の 2 つの引数を取ります。

ProfileName: 署名を見つけるために必要なプロファイル ドキュメント名は「calendarprofile」です。(はい、そうです。これは実際には多くの機能に共通のプロファイルですが、カレンダー開発者が最初にそこに到達して名前を付けました。;-))

UniqueKey: これは空の文字列のままにします。(共有データベースのプロファイル文書にユーザー名を保存するために伝統的に使用されますが、メールファイルの calendarprofile 文書では使用されません。)

getItem()、getItemValue() などを使用して、通常の文書にアクセスするのと同じ方法でプロファイル文書のデータにアクセスします。単純なテキスト署名の場合、探している NotesItem は「署名」と呼ばれます。しかし、「Signature_1」「Signature_2」「SignatureOption」という項目もあることに気がつきました。

Notes メールで署名を設定するためのプリファレンス UI を見ると、単純なテキストと HTML またはグラフィック ファイルのどちらかを選択できることがわかります。この選択が SignatureOption 項目に反映されることは間違いないので、最初に確認することをお勧めします。インポートした HTML ファイルまたはグラフィック ファイルを使用する場合、データがどこに移動するかは調べていません。ただし、NotesPeek を使用して自分で調べることができます。ここからダウンロードできます. NSF ファイルのツリー形式のビューが表示されます。プロファイルのツリーのブランチがあり、そこに calendarprofile があります。次に、Notes のメール設定でさまざまな設定を試してみて、何が変わるか見てみましょう。(NotesPeek はその場で変更を取得しません。変更を表示するには、Notes メール設定ダイアログで変更を保存した後、NotesPeek でプロファイルを閉じてから再度開く必要があります。)

于 2013-01-11T17:42:13.453 に答える
0

これが難しすぎて、すべてのメールに標準のソリューションが必要な場合は、この製品または類似の製品を検討してください。

于 2013-01-12T10:47:15.607 に答える