Enfin, je pourrais le faire de la manière suivante. Et j'ai pensé à le poster à quelqu'un qu'on peut au moins ne pas souffrir à nouveau.
Le code suivant est de lire la pièce jointe des courriels de lotus et de l'enregistrer dans l'emplacement physique.
chaîne lotusServerName = ConfigurationSettings.AppSettings ["Lotus_Server"]. ToString(); chaîne lotusDBFilePath = ConfigurationSettings.AppSettings ["Lotus_DB_File_Path"]. ToString(); string password = ConfigurationSettings.AppSettings ["Mot de passe"]. ToString(); chaîne 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;
Voici les valeurs lues dans le fichier .config.
Le code ci-dessus fonctionnera correctement si vous avez alredy client de messagerie Lotus dans votre système et vous êtes en mesure d'accéder à la messagerie de votre serveur de messagerie. Vous n'avez pas besoin d'autres previliges.