我有一個使用win32com.client從Python連接到Lotus Notes的問題。在python中使用win32com.client時無法打開ID文件
我使用下面的代碼:
import win32com.client
import csv # imports the csv module
import sys # imports the sys module
import re
notesServer = "AALMBX01/Server/..."
notesPass = "PASS"
#Connect to notes database on server
notesSession = win32com.client.Dispatch('Lotus.NotesSession')
notesSession.Initialize(notesPass)
db_name = 'mail\iizs.nsf'
db = notesSession.getDatabase(notesServer, db_name)
view = db.GetView("($All)")
doc = view.getFirstDocument()
而且我得到以下錯誤:
(-2147352567, 'Exception occurred.', (0, u'NotesSession', u'Notes error: Wrong Password. (Passwords are case sensitive - be sure to use correct upper and lower case.)'
還試圖離開密碼留空並禁用「爲LN應用要求密碼」的界面。使用空白密碼,我收到以下錯誤消息:
(-2147352567, 'Exception occurred.', (0, u'NotesDatabase', u'Database AALMBX01/Server/...!!mail\iizs.nsf has not been opened yet'
我曾嘗試以下:
- 使用lnlib和get_session功能。
- 檢查notus.ini文件是否到位(在我的情況下是C:\ Users \ iizs \ NotesData),幷包含對userid的引用(嘗試將用戶ID文件的完整路徑添加到C:\ Users \ iizs \ Notes數據\數據)。
- 添加值HKEY_CURRENT_USER \ SOFTWARE \蓮花\註釋(可選的版本)\的NotesIniPath
- 加入含有notes.ini文件的文件夾(C:\ Users \用戶iizs \ Notes數據)和user.id文件(C: \ Users \ iizs \ NotesData \ data)添加到PATH環境變量中。
錯誤仍然是一樣的。試圖將user.id複製到系統文件夾之一(system32) - 也沒有幫助。
有什麼建議嗎?
謝謝你的評論!現在我收到一條錯誤消息:「(-2147352567,'發生了異常',(0,u'NotesSession',u'Notes錯誤:密碼錯誤(密碼區分大小寫 - 請務必使用正確的大寫和小寫。'',None,0,-2147217504),None)「。我當然使用正確的密碼,請問可能會有什麼問題? –
此外,當我試圖離開密碼空白,它連接正常,但然後我得到一個錯誤在GetView()說:「數據庫...還沒有打開過。」有什麼建議? –
我沒有打錯誤之前,但要確保你的Python腳本在單引號(例如'password')中有你的密碼,而不是雙引號(例如「password」),因爲有些語言試圖'解釋'字符串。我不知道這種語言是否屬實,但它是其他地方的障礙...... – neophytte