Наконец, я мог бы сделать это следующим образом.И я подумал о том, чтобы отправить его кому-нибудь, чтобы не страдать снова.
Следующий код - прочитать вложение из писем лотоса и сохранить его в физическом месте.
string lotusServerName =ConfigurationSettings.AppSettings [ "Lotus_Server"] ToString ().;string lotusDBFilePath = ConfigurationSettings.AppSettings ["Lotus_DB_File_Path"]. ToString ();строка password = ConfigurationSettings.AppSettings ["Пароль"]. ToString ();string sourceFolder = ConfigurationSettings.AppSettings ["Source_Folder"]. ToString ();string targetFolder = ConfigurationSettings.AppSettings ["Target_Folder"]. ToString ();string documentsFolder = ConfigurationSettings.AppSettings ["Documents_Folder"]. ToString ();
//Creating the notes session and passing password
NotesSession session = new NotesSession();
session.Initialize(password);
//Getting the DB instance by passing the servername and path of the mail file.
//third param "false" will try to check the DB availability by opening the connection
//if it cannot open, then it returns null.
NotesDatabase NotesDb = session.GetDatabase(lotusServerName, lotusDBFilePath, false);
//Get the view of the source folder
NotesView inbox = NotesDb.GetView(sourceFolder);
//looping through each email/document and looking for the attachments
//if any attachments found, saving them to the given specified location
//moving the read mails to the target folder
NotesDocument docInbox = null;
int docCnt = inbox.EntryCount;
for (int currDoc = 0; currDoc < docCnt; currDoc++) {
docInbox = inbox.GetFirstDocument();
object[] items = (object[])docInbox.Items;
foreach (NotesItem nItem in items) {
if (nItem.Name == "$FILE") {
NotesItem file = docInbox.GetFirstItem("$File");
string fileName = ((object[])nItem.Values)[0].ToString();
NotesEmbeddedObject attachfile = (NotesEmbeddedObject)docInbox.GetAttachment(fileName);
if (attachfile != null) {
attachfile.ExtractFile(documentsFolder + fileName);
}
}
}
docInbox.PutInFolder(targetFolder, true);//"true" creates the folder if it doesn't exists
docInbox.RemoveFromFolder(sourceFolder);
}
//releasing resources
if (session != null)
session = null;
if (NotesDb != null)
NotesDb = null;
if (inbox != null)
inbox = null;
if (docInbox != null)
docInbox = null;
Ниже приведены значения, считанные из файла .config.
Приведенный выше код будетработать правильно, если у вас уже есть почтовый клиент lotus в вашей системе, и вы можете получить доступ к почте с вашего почтового сервера.Вам не нужны никакие другие предпочтения.