I read the docment :
在 Microsoft .NET 应用程序中使用 IBM Lotus Domino
看下面代码,用VB写的:
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
If Not (ns Is Nothing) Then
ns.Initialize("password")
db = ns.GetDatabase("ServerName//Domain", "names.nsf", False)
If Not (db Is Nothing) Then
doc = db.CreateDocument()
doc.ReplaceItemValue("Form", "Memo")
doc.ReplaceItemValue("SendTo", cboNames.SelectedText + "//Domain")
doc.ReplaceItemValue("Subject", txtSubject.Text)
Dim rt As NotesRichTextItem
rt = doc.CreateRichTextItem("Body")
rt.AppendText(rtbBody.Text)
doc.Send(False)
rt = Nothing
doc = Nothing
lblMessage.Text = "Message Sent."
End If
db = Nothing
ns = Nothing
End If
Catch ex As Exception
lblMessage.Text = "Error: " + ex.Message.ToString()
根据这些我用C#重写了一遍,想要实现从Domino数据库中打开一个DOCument.
public class VD
{
NotesSession notesS = new NotesSession();
NotesDatabase notesDB = new NotesDatabase();
NotesDocument notesDoc = new NotesDocument();
public VD()
{
try
{
if(notesS!=null)
{
notesS.Initialize("*****");
notesDB = notesS.GetDatabase("*****", "*******", false);
}
}
catch
{
}
}
}
结果无法 使用 VD vd1=new VD();
抛出一个 错误
修改为:
public class VD
{
NotesSession notesS ;
NotesDatabase notesDB ;
NotesDocument notesDoc ;
public VD()
{
try
{
notesS.Initialize("*****");
notesDB = notesS.GetDatabase("*****", "*******", false);
}
catch
{
}
}
}
抛出Object reference not set to an instance of an object. 错误
想了想问题可能出现在类型 NotesSession , NotesDatabase , NotesDocument 是INTerface. 这方面我很薄弱。下功夫。。。。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12591435/viewspace-79973/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12591435/viewspace-79973/