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]);