我有一个c#类,用于读取Lotus电子邮件中的任何附件并将其保存到本地驱动器。当我将“”作为第一个参数传递给GetDataBase方法并将本地系统的.nsf文件的完整路径作为第二个参数传递时,它工作正常。但是,如果我删除“”并且我将本地系统全名指定为第一个参数,则返回空值。
任何权限都有问题吗?如果是这样,即使我将“”作为第一个参数传递,它也不应该工作。否则,我应该在系统/服务器级别拥有任何其他权限吗? 请帮我解决这个问题。
答案 0 :(得分:2)
最后,我可以通过以下方式完成。而且我想把它发布给一些人至少不会再受苦了。
以下代码是从lotus电子邮件中读取附件并将其保存到物理位置。
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文件中读取的值。
如果您在系统中拥有Lotus邮件客户端并且您可以从邮件服务器访问邮件,则上述代码将正常工作。您不需要任何其他优惠。