Dennis Wallentin
asked on
Retrieve signature in Lotus Notes 7
Hi all,
The following snippet code works as expected in classic VB (using early binding with reference to Lotus Domino) in that it retrieve the signature in plain text:
stSignature = db.GetProfileDocument("Cal endarProfi le").GetFi rstItem("S ignature") .Text
How should I do to retrieve the same information when using VB.NET?
TIA,
Dennis
The following snippet code works as expected in classic VB (using early binding with reference to Lotus Domino) in that it retrieve the signature in plain text:
stSignature = db.GetProfileDocument("Cal
How should I do to retrieve the same information when using VB.NET?
TIA,
Dennis
ASKER
Why would I need to add a reference to Lotus Notes Automation Class when it already exist a reference to the Domino Object class?
As I mentioned in my first post the only issue I got is to retrieve the signature (which is plain text and not in HTML). Other then that it works without any issues in VB.NET :-)
BTW, would it be better if I asked about it in the Lotus Notes/Domino forum?
Kind regards,
Dennis
As I mentioned in my first post the only issue I got is to retrieve the signature (which is plain text and not in HTML). Other then that it works without any issues in VB.NET :-)
BTW, would it be better if I asked about it in the Lotus Notes/Domino forum?
Kind regards,
Dennis
I was trying to figure out from your vague description what where you were having a problem. You were talking about classic VB6, and so I wanted to make sure that you had all the references in VB.NET.
1) Are you getting exceptions when you try to accomplish the same thing with VB.NET?
2) What problems are having, if they aren't errors?
3) What .NET version are you using? 2002, 2003 or 2005?
Bob
1) Are you getting exceptions when you try to accomplish the same thing with VB.NET?
2) What problems are having, if they aren't errors?
3) What .NET version are you using? 2002, 2003 or 2005?
Bob
ASKER
Bob,
I'm not used to ask questions rather answer questions ;)
It turned out to be a casting issue which finally made it possible to solve the issue.
Platform: VB.NET 2005 with Option Strict On
Notes Client: 7.0.1
Domino Object class: 2.1 - Early binding
The following snippet code shows the solution:
'Instantiate the session.
Dim notSession As New Domino.NotesSessionClass
CType(notSession, Domino.NotesSession).Initi alize("")
'Open the local mail database.
Dim notMailDb As Domino.NotesDatabase = CType(notSession, Domino.NotesSessionClass). GetDbDirec tory("").O penMailDat abase
'Grab the profile that holds the signature which will be added to the outgoing e-mail.
Dim notProfile As Domino.NotesDocument = CType(notMailDb.GetProfile Document(" CalendarPr ofile"), Domino.NotesDocument)
'Grab the signature, which only can be done with signature in plain test.
Dim stSignature As String = CStr(notProfile.GetFirstIt em("Signat ure").Text )
'Create the outgoing e-mail
I hope that the above can help other developers as well.
Kind regards,
Dennis
I'm not used to ask questions rather answer questions ;)
It turned out to be a casting issue which finally made it possible to solve the issue.
Platform: VB.NET 2005 with Option Strict On
Notes Client: 7.0.1
Domino Object class: 2.1 - Early binding
The following snippet code shows the solution:
'Instantiate the session.
Dim notSession As New Domino.NotesSessionClass
CType(notSession, Domino.NotesSession).Initi
'Open the local mail database.
Dim notMailDb As Domino.NotesDatabase = CType(notSession, Domino.NotesSessionClass).
'Grab the profile that holds the signature which will be added to the outgoing e-mail.
Dim notProfile As Domino.NotesDocument = CType(notMailDb.GetProfile
'Grab the signature, which only can be done with signature in plain test.
Dim stSignature As String = CStr(notProfile.GetFirstIt
'Create the outgoing e-mail
I hope that the above can help other developers as well.
Kind regards,
Dennis
Thank you Dennis. I have worked with Lotus, but not with .NET. That information may prove to be helpful.
Asking questions is an artform that more people should embrace ;)
Bob
Asking questions is an artform that more people should embrace ;)
Bob
ASKER
Bob,
I will keep this thread open as it may come new issues along the road before the solution is complete. After all, working with Lotus through COM is not an easy task.
Kind regards,
Dennis
I will keep this thread open as it may come new issues along the road before the solution is complete. After all, working with Lotus through COM is not an easy task.
Kind regards,
Dennis
ASKER
To the TA administrator:
I wish to close this question and since I found out the solution myself I would suggest that the points are refunded.
Kind regards,
Dennis
I wish to close this question and since I found out the solution myself I would suggest that the points are refunded.
Kind regards,
Dennis
ASKER
Hi all,
Below is the function I finally created which is called from Excel:
'Function to create e-mail, add attachments and send.
Function Create_Email_Notes(ByVal stPriority As String, _
ByVal stSubject As String, _
ByVal oSendTo As Object, _
ByVal oSendCopy As Object, _
ByVal stMessage As String, _
ByVal bFlag As Boolean, _
Optional ByVal stFile As String = "", _
Optional ByVal oFiles As Object = "") As Boolean
'Create and instantiate the Lotus Notes session.
Dim notSession As New Domino.NotesSessionClass
CType(notSession, Domino.NotesSession).Initi alize("")
'Open the local mail database.
Dim notMailDb As Domino.NotesDatabase = CType(notSession, Domino.NotesSessionClass). GetDbDirec tory("").O penMailDat abase
'Grab the profile that holds the signature which will be added to the outgoing e-mail.
Dim notProfile As Domino.NotesDocument = CType(notMailDb.GetProfile Document(" CalendarPr ofile"), Domino.NotesDocument)
'Grab the signature, which only can be done with signatures in plain text.
Dim stSignature As String = CStr(notProfile.GetFirstIt em("Signat ure").Text )
'Create the outgoing e-mail.
Dim notDoc As Domino.NotesDocument = CType(notMailDb.CreateDocu ment, Domino.NotesDocument)
'Create the body space in the outgoing e-mail.
Dim notItem As Domino.NotesRichTextItem = CType(notDoc.CreateRichTex tItem("Bod y"), Domino.NotesRichTextItem)
'Create the attachment space in the outgoing e-mail.
Dim notAttach As Domino.NotesRichTextItem = CType(notDoc.CreateRichTex tItem("STF ILE"), Domino.NotesRichTextItem)
'Declare the variable for attached file(s).
Dim notEmbedded As Domino.NotesEmbeddedObject
If bFlag Then
'Add the created file as attachment to the outgoing e-mail.
notEmbedded = CType(notAttach.EmbedObjec t(EMBED_TY PE.EMBED_A TTACHMENT, "", stFile), Domino.NotesEmbeddedObject )
Else
'Add the files as attachments to the outgoing e-mail.
Dim oItem As Object
For Each oItem In CType(oFiles, Array)
notEmbedded = CType(notAttach.EmbedObjec t(EMBED_TY PE.EMBED_A TTACHMENT, "", CStr(oItem)), Domino.NotesEmbeddedObject )
Next
End If
Try
'Populate the outgoing e-mail's main properties.
With notDoc
.AppendItemValue("Form", "Memo")
.AppendItemValue("Subject" , stSubject)
.AppendItemValue("SendTo", oSendTo)
.AppendItemValue("CopyTo", oSendCopy)
.AppendItemValue("Delivery Priority", stPriority)
With notItem
.AppendText(stMessage & vbCrLf & vbCrLf)
.AppendText(stSignature & vbCrLf & vbCrLf)
End With
.SaveMessageOnSend = True
.Send(True, "")
End With
'Set the status for the function to the calling sub.
Create_Email_Notes = True
Catch ex As Exception
MessageBox.Show(ex.ToStrin g)
'Set the status for the function to the calling sub.
Create_Email_Notes = False
Finally
'Place variables to be handled by the Garbage Collector (GC).
notEmbedded = Nothing
notAttach = Nothing
notItem = Nothing
notProfile = Nothing
notDoc = Nothing
notMailDb = Nothing
notSession = Nothing
End Try
End Function
Kind regards,
Dennis
Below is the function I finally created which is called from Excel:
'Function to create e-mail, add attachments and send.
Function Create_Email_Notes(ByVal stPriority As String, _
ByVal stSubject As String, _
ByVal oSendTo As Object, _
ByVal oSendCopy As Object, _
ByVal stMessage As String, _
ByVal bFlag As Boolean, _
Optional ByVal stFile As String = "", _
Optional ByVal oFiles As Object = "") As Boolean
'Create and instantiate the Lotus Notes session.
Dim notSession As New Domino.NotesSessionClass
CType(notSession, Domino.NotesSession).Initi
'Open the local mail database.
Dim notMailDb As Domino.NotesDatabase = CType(notSession, Domino.NotesSessionClass).
'Grab the profile that holds the signature which will be added to the outgoing e-mail.
Dim notProfile As Domino.NotesDocument = CType(notMailDb.GetProfile
'Grab the signature, which only can be done with signatures in plain text.
Dim stSignature As String = CStr(notProfile.GetFirstIt
'Create the outgoing e-mail.
Dim notDoc As Domino.NotesDocument = CType(notMailDb.CreateDocu
'Create the body space in the outgoing e-mail.
Dim notItem As Domino.NotesRichTextItem = CType(notDoc.CreateRichTex
'Create the attachment space in the outgoing e-mail.
Dim notAttach As Domino.NotesRichTextItem = CType(notDoc.CreateRichTex
'Declare the variable for attached file(s).
Dim notEmbedded As Domino.NotesEmbeddedObject
If bFlag Then
'Add the created file as attachment to the outgoing e-mail.
notEmbedded = CType(notAttach.EmbedObjec
Else
'Add the files as attachments to the outgoing e-mail.
Dim oItem As Object
For Each oItem In CType(oFiles, Array)
notEmbedded = CType(notAttach.EmbedObjec
Next
End If
Try
'Populate the outgoing e-mail's main properties.
With notDoc
.AppendItemValue("Form", "Memo")
.AppendItemValue("Subject"
.AppendItemValue("SendTo",
.AppendItemValue("CopyTo",
.AppendItemValue("Delivery
With notItem
.AppendText(stMessage & vbCrLf & vbCrLf)
.AppendText(stSignature & vbCrLf & vbCrLf)
End With
.SaveMessageOnSend = True
.Send(True, "")
End With
'Set the status for the function to the calling sub.
Create_Email_Notes = True
Catch ex As Exception
MessageBox.Show(ex.ToStrin
'Set the status for the function to the calling sub.
Create_Email_Notes = False
Finally
'Place variables to be handled by the Garbage Collector (GC).
notEmbedded = Nothing
notAttach = Nothing
notItem = Nothing
notProfile = Nothing
notDoc = Nothing
notMailDb = Nothing
notSession = Nothing
End Try
End Function
Kind regards,
Dennis
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob