ovalsquare
asked on
Open new email message in Lotus Notes from within a .NET Windows application
All,
This is an annoying one. I'm sure it's been done countless times, but there does not appear to be a vb.net or C#.Net working sample out there (only many VB6 etc. which for various reasons do not completely transition).
I need to open a new email message in LotusNotes from within a vb.net application, with subject, body, etc. populated including attachments also attached. I've done it before to interop with Outlook, but can't find the equivalent for LotusNotes (v6.5), but need to do so so that the user can modify the body, and most importantly, access their LotusNotes address book.
I have SENT an email using Lotus Notes with information from my VB.NET app, but I need it to just open up a new mail message so that there is access to the Lotus Notes address book/s.
Alternatively, if someone can help point out how to access a LotusNotes address book from within a vb.net/c#.net application, that would work just as well.
Much thanks in advance,
Ted
This is an annoying one. I'm sure it's been done countless times, but there does not appear to be a vb.net or C#.Net working sample out there (only many VB6 etc. which for various reasons do not completely transition).
I need to open a new email message in LotusNotes from within a vb.net application, with subject, body, etc. populated including attachments also attached. I've done it before to interop with Outlook, but can't find the equivalent for LotusNotes (v6.5), but need to do so so that the user can modify the body, and most importantly, access their LotusNotes address book.
I have SENT an email using Lotus Notes with information from my VB.NET app, but I need it to just open up a new mail message so that there is access to the Lotus Notes address book/s.
Alternatively, if someone can help point out how to access a LotusNotes address book from within a vb.net/c#.net application, that would work just as well.
Much thanks in advance,
Ted
Lotus C API Notes/Domino 6.5 Reference (G210-1737-00) 2004-03-19
Provides reference material for Release 6.5 of the Lotus Notes
http://www.elink.ibmlink.ibm.com/public/applications/publications/cgibin/pbi.cgi?CTY=US&FNC=SRX&PBL=G210-1737-00
Provides reference material for Release 6.5 of the Lotus Notes
http://www.elink.ibmlink.ibm.com/public/applications/publications/cgibin/pbi.cgi?CTY=US&FNC=SRX&PBL=G210-1737-00
I'm afraid you need some connector to do this, like Domino has DIIOP for Java to make it work. See www.proposion.com for one example
There is also ODBC.NET and NotesSQL that has an ODBC driver.
There is also ODBC.NET and NotesSQL that has an ODBC driver.
ASKER
SysExpert: well...appreciate the somewhat better direction, but I'm looking for C#.NET or VB.NET, not the C API. I'm going to dig into it further, but thus far, I have trouble believing there are no better samples out there for doing what must be a fairly common scenario.
sjef_bosman: Just what I'm looking for other than Single developer - US $795. Ouch! You've got to be kidding me! I just want access to the address book which there should be no need to go so high-powered.
Here's what I've got that functions to send off an email (although doesn't open it up for further editing, requires email address, etc.):
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
'Start a session to notes
Session = CreateObject("Notes.NotesS ession")
'Open the mail database in notes
Maildb = Session.GETDATABASE("", "C:\Program Files\lotus\notes\data\mai l\ted.nsf" )
If Not Maildb.IsOpen = True Then
Maildb.Open()
End If
'Create the mail document
MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
'Set the recipient
MailDoc.sendto = "ted@somewhere.com"
'Set subject
MailDoc.Subject = "Subject text"
'Create and set the Body content
Body = MailDoc.CREATERICHTEXTITEM ("Body")
Call Body.APPENDTEXT("Body text here")
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
'Call Body.EMBEDOBJECT(1454, "", "C:\filename", "Attachment")
'Example to save the message (optional)
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the Sent items folder
Call MailDoc.SEND(False)
'Clean Up
Maildb = Nothing
MailDoc = Nothing
Body = Nothing
Session = Nothing
Of course, it's not all really updated to .NET, but it works. Because it does, again, I have trouble believing there's not a simple solution already existing out there that will open up a new email with the Body and Subject already specified, but with To: field empty etc. I've done it with Outlook, Outlook Express, written an internal email application, but hooking it up with Lotus is rather interesting.
Thanks for any and all help!
Ted
sjef_bosman: Just what I'm looking for other than Single developer - US $795. Ouch! You've got to be kidding me! I just want access to the address book which there should be no need to go so high-powered.
Here's what I've got that functions to send off an email (although doesn't open it up for further editing, requires email address, etc.):
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
'Start a session to notes
Session = CreateObject("Notes.NotesS
'Open the mail database in notes
Maildb = Session.GETDATABASE("", "C:\Program Files\lotus\notes\data\mai
If Not Maildb.IsOpen = True Then
Maildb.Open()
End If
'Create the mail document
MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
'Set the recipient
MailDoc.sendto = "ted@somewhere.com"
'Set subject
MailDoc.Subject = "Subject text"
'Create and set the Body content
Body = MailDoc.CREATERICHTEXTITEM
Call Body.APPENDTEXT("Body text here")
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
'Call Body.EMBEDOBJECT(1454, "", "C:\filename", "Attachment")
'Example to save the message (optional)
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the Sent items folder
Call MailDoc.SEND(False)
'Clean Up
Maildb = Nothing
MailDoc = Nothing
Body = Nothing
Session = Nothing
Of course, it's not all really updated to .NET, but it works. Because it does, again, I have trouble believing there's not a simple solution already existing out there that will open up a new email with the Body and Subject already specified, but with To: field empty etc. I've done it with Outlook, Outlook Express, written an internal email application, but hooking it up with Lotus is rather interesting.
Thanks for any and all help!
Ted
Sorry, I missed some essential points in your question. You wrote:
> I have SENT an email using Lotus Notes with information from my VB.NET app,
> but I need it to just open up a new mail message so that there is access to the
> Lotus Notes address book/s.
So, apparently, COM works from VB.NET, like it does from VB. Now you say you want to update an address book. Is that the Local, Personal Address book, or is it the Address book on the server?
And what do you mean by
> so that there is access to the Lotus Notes address book/s
Do you want to read names and mail-addresses from the Address book? That would be easy, something like this (in LS):
Dim ab As Variant
Dim aview As NotesView
Dim adoc As NotesDocument
Dim adb As NotesDatabase
ab= Session.AddressBooks
Forall abi In ab ' get the first local address book
If abi.IsPrivateAddressBook Then
Set adb= abi
Exit Sub
End If
End If
If adb Is Nothing Then Exit Sub
If Not adb.IsOpen Then Call adb.Open("","")
If Not adb.IsOpen Then Exit Sub
Set aview= adb.GetView("($PeopleGroup sFlat)")
Set adoc= aview.GetFirstDocument
Do While Not (adoc Is Nothing)
' now adoc.ColumnValues(1) is the user's name or the group name
' and adoc.ColumnValues(2) is the mail address
Set adoc= aview.GetNextDocument(adoc )
Loop
Like this?
> I have SENT an email using Lotus Notes with information from my VB.NET app,
> but I need it to just open up a new mail message so that there is access to the
> Lotus Notes address book/s.
So, apparently, COM works from VB.NET, like it does from VB. Now you say you want to update an address book. Is that the Local, Personal Address book, or is it the Address book on the server?
And what do you mean by
> so that there is access to the Lotus Notes address book/s
Do you want to read names and mail-addresses from the Address book? That would be easy, something like this (in LS):
Dim ab As Variant
Dim aview As NotesView
Dim adoc As NotesDocument
Dim adb As NotesDatabase
ab= Session.AddressBooks
Forall abi In ab ' get the first local address book
If abi.IsPrivateAddressBook Then
Set adb= abi
Exit Sub
End If
End If
If adb Is Nothing Then Exit Sub
If Not adb.IsOpen Then Call adb.Open("","")
If Not adb.IsOpen Then Exit Sub
Set aview= adb.GetView("($PeopleGroup
Set adoc= aview.GetFirstDocument
Do While Not (adoc Is Nothing)
' now adoc.ColumnValues(1) is the user's name or the group name
' and adoc.ColumnValues(2) is the mail address
Set adoc= aview.GetNextDocument(adoc
Loop
Like this?
ASKER
sjef_bosman,
Now we're getting there.
Yes, COM works with VB.NET.
1. I have been assuming that I'm only dealing with the local Personal Address Book. But in case not, how would I access the shared public Address Book on the server? I wish there was some decent documentation on the Lotus COM implementation.
2. Yes, read names and mail-addresses from the Address Book.
Question:
What exactly is abi? As in, Forall abi in ab 'get the first local address book. I need to actually declare it and can't seem to figure out its data type.
For each abi As WHAT? In ab
' get the first local address book
If abi.IsPrivateAddressBook Then
adb = abi
Exit Sub
End If
Next
Forgive me as this is the first time I've tried to interop with Lotus (and my experience thus far doesn't make me want to be become any less of a newbie with it ;-)
Thanks,
Ted
Now we're getting there.
Yes, COM works with VB.NET.
1. I have been assuming that I'm only dealing with the local Personal Address Book. But in case not, how would I access the shared public Address Book on the server? I wish there was some decent documentation on the Lotus COM implementation.
2. Yes, read names and mail-addresses from the Address Book.
Question:
What exactly is abi? As in, Forall abi in ab 'get the first local address book. I need to actually declare it and can't seem to figure out its data type.
For each abi As WHAT? In ab
' get the first local address book
If abi.IsPrivateAddressBook Then
adb = abi
Exit Sub
End If
Next
Forgive me as this is the first time I've tried to interop with Lotus (and my experience thus far doesn't make me want to be become any less of a newbie with it ;-)
Thanks,
Ted
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sjef_bosman,
Woohoo!
Now I'm finally tapping into the contacts database! The lotus.net/doc link is no longer functioning, but the magical words "Domino Designer" manuals and google got me to http://www.e-promag.com/epLotusDocFinder/appdev/dominodesigner.cfm which, although outdated and only VB6, got me pointed in the right direction. I'm running out the door right now, but will accept the answer and post my final working solution when I get back into town on Monday morning.
And LotusScript...hmmm...it's like taking a way back machine - but no worries, we won't bring politics into this.
Much much thanks.
Ted
Woohoo!
Now I'm finally tapping into the contacts database! The lotus.net/doc link is no longer functioning, but the magical words "Domino Designer" manuals and google got me to http://www.e-promag.com/epLotusDocFinder/appdev/dominodesigner.cfm which, although outdated and only VB6, got me pointed in the right direction. I'm running out the door right now, but will accept the answer and post my final working solution when I get back into town on Monday morning.
And LotusScript...hmmm...it's like taking a way back machine - but no worries, we won't bring politics into this.
Much much thanks.
Ted
Oh, heck, I meant www.lotus.com/doc
By the way, did you know that COBOL is still heavily used all over the world? Talking about "way back"...
By the way, did you know that COBOL is still heavily used all over the world? Talking about "way back"...
Hey Ted,
As long as Lotus Notes is the default mail application on the machine, you could simply use a mailto:-type link*. While I'm not completely certain that you can make web-based/URL-based calls in your application, this will allow you to present a pre-formatted message that the user can just send. The best part about using this type of solution - should your clients move away from Lotus Notes to another mail client, this part of your solution will still work without modification!
* - Check out more information on mailto-type links and it's attributes here: http://www.ianr.unl.edu/internet/mailto.html
HTH,
-Chris
As long as Lotus Notes is the default mail application on the machine, you could simply use a mailto:-type link*. While I'm not completely certain that you can make web-based/URL-based calls in your application, this will allow you to present a pre-formatted message that the user can just send. The best part about using this type of solution - should your clients move away from Lotus Notes to another mail client, this part of your solution will still work without modification!
* - Check out more information on mailto-type links and it's attributes here: http://www.ianr.unl.edu/internet/mailto.html
HTH,
-Chris
ASKER
Will be posting working code and closing this question sometime this week.
Chris, appreciate the input and I wish it could have been as simply as putting a nice web-base call in the application, but it's not as simple as that (and not the first time I've wished that).
Thanks,
Ted
Chris, appreciate the input and I wish it could have been as simply as putting a nice web-base call in the application, but it's not as simple as that (and not the first time I've wished that).
Thanks,
Ted
ASKER
fyi: here's basic functional code for accessing addresses in Notes. And thanks for pointing me in the right direction. The only thing concerning me is that there's no disposal of the Notes objects.... oh well.
Private Sub PopulateAddressBooks()
Dim session As New NotesSession
Dim book As NotesDatabase
Try
session.Initialize()
For Each book In session.AddressBooks
If Not book.IsOpen Then book.Open()
If Not book.IsOpen Then Exit Sub
AddressBooks.Items.Add(boo k.Title)
Next
Catch ex As Exception
MessageBox.Show(ex.ToStrin g, "Error populating Address Book List", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub PopulateAddresses(ByVal BookTitle As String)
Dim session As New NotesSession
Dim book As NotesDatabase
Dim view As NotesView
Dim document As NotesDocument
Try
session.Initialize()
For Each book In session.AddressBooks
If book.Title = BookTitle Then
Addresses.Items.Clear()
If Not book.IsOpen Then book.Open()
If Not book.IsOpen Then Exit Sub
view = book.GetView("($PeopleGrou psFlat)")
document = view.GetFirstDocument
While Not document Is Nothing
Addresses.Items.Add(String .Format("{ 0} [{1}]", document.ColumnValues(1).T oString, document.ColumnValues(2)))
document = view.GetNextDocument(docum ent)
End While
End If
Next
Catch ex As Exception
MessageBox.Show(ex.ToStrin g, "Error populating Address List from " & BookTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub PopulateAddressBooks()
Dim session As New NotesSession
Dim book As NotesDatabase
Try
session.Initialize()
For Each book In session.AddressBooks
If Not book.IsOpen Then book.Open()
If Not book.IsOpen Then Exit Sub
AddressBooks.Items.Add(boo
Next
Catch ex As Exception
MessageBox.Show(ex.ToStrin
End Try
End Sub
Private Sub PopulateAddresses(ByVal BookTitle As String)
Dim session As New NotesSession
Dim book As NotesDatabase
Dim view As NotesView
Dim document As NotesDocument
Try
session.Initialize()
For Each book In session.AddressBooks
If book.Title = BookTitle Then
Addresses.Items.Clear()
If Not book.IsOpen Then book.Open()
If Not book.IsOpen Then Exit Sub
view = book.GetView("($PeopleGrou
document = view.GetFirstDocument
While Not document Is Nothing
Addresses.Items.Add(String
document = view.GetNextDocument(docum
End While
End If
Next
Catch ex As Exception
MessageBox.Show(ex.ToStrin
End Try
End Sub
Thanks for the points, and glad to have been of some help. I can understand the B...
> Will be posting working code and closing this question sometime this week.
Which week? ;)
Sjef
> Will be posting working code and closing this question sometime this week.
Which week? ;)
Sjef
ASKER
Oh, and I'm having to do some after the fact handling of email addresses being brought in dependant upon whether it's stored as an "internet e-mail address" or "Notes address" within Notes.
Ted
Ted
Ah... Once again, I should have refreshed before posting...
So sorry... :$
So sorry... :$
http://www-130.ibm.com/developerworks/lotus/
I hope this helps !