我有一個c#類,它被寫爲讀取任何附件的蓮花郵件並將其保存到本地驅動器。當我作爲第一個參數傳遞GetDataBase方法和本地系統的.nsf文件的完整路徑作爲第二個參數時,它工作正常。但是,如果我刪除「」,並指定我的本地系統全名作爲第一個參數,它將返回空值。NotesSession.GetDataBase方法返回空值
是否有任何權限問題?如果是這樣,即使我將「」作爲第一個參數傳遞,也不應該起作用。否則,我應該在系統/服務器級別擁有任何其他權限嗎? 請幫我解決這個問題。
我有一個c#類,它被寫爲讀取任何附件的蓮花郵件並將其保存到本地驅動器。當我作爲第一個參數傳遞GetDataBase方法和本地系統的.nsf文件的完整路徑作爲第二個參數時,它工作正常。但是,如果我刪除「」,並指定我的本地系統全名作爲第一個參數,它將返回空值。NotesSession.GetDataBase方法返回空值
是否有任何權限問題?如果是這樣,即使我將「」作爲第一個參數傳遞,也不應該起作用。否則,我應該在系統/服務器級別擁有任何其他權限嗎? 請幫我解決這個問題。
最後,我可以用下面的方法做到這一點。我想把它發佈給某人,至少不會再遭受痛苦。
以下代碼是從蓮花郵件中讀取附件並將其保存到物理位置。
string lotusServerName = ConfigurationSettings.AppSettings [「Lotus_Server」]。ToString(); string lotusDBFilePath = ConfigurationSettings.AppSettings [「Lotus_DB_File_Path」]。ToString(); string password = ConfigurationSettings.AppSettings [「Password」]。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文件讀取的值。
上面的代碼將正常工作,如果你有alredy蓮花郵件客戶端在你的系統,你可以從你的郵件服務器訪問郵件。你不需要任何其他previliges。