我正在编写一个程序,我可以在其中从三个不同的部门邮箱(每个使用自己的邮件服务器和 nsf 文件)发送邮件(使用 domino.dll)。所有三个部门邮箱都有一个预定义的邮件签名,例如
问候 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]);