Hammer8
asked on
Loop Through Emails in Notes Client in VBA Excel
Hi, I wonder if there is a way in VBA Excel to loop through each email in my Notes inbox (or which ever folder is currently open in the Notes Client); pulling the text off each email as they are looped through. Thanks, Hammer8
ASKER
just text is sufficient. I want to store the txt in an access db. thanks.
Here is a nice piece of code:
http://www.softnet.co.za/hats.nsf/9931ef84d582099e4225654c004ae8ad/1d9713791ee7885b42256937004a62d7?OpenDocument
http://www.softnet.co.za/hats.nsf/9931ef84d582099e4225654c004ae8ad/1d9713791ee7885b42256937004a62d7?OpenDocument
And maybe even a better one for this purpose:
'ExportToAccess:
Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim strDB As String
Dim dbq As String
Dim ConnectionString As String
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If (dc.Count > 0) Then
strDB = "C:\Newdb4.mdb" ' this is a hardcoded path
'allow user to redifine mdb path
strDB = Inputbox$("Enter mdb path: ","New mdb path", strDB)
dbq = "; Dbq=" & strDB
Forall DSN In con.ListDataSources
If (Instr(1,dsn, "Access") > 0) Then ConnectionString = DSN & dbq
End Forall
If Not con.ConnectTo( ConnectionString ) Then
Messagebox "Could not connect to: " & ConnectionString
Exit Sub
Else
Messagebox "Connected to: " & ConnectionString
End If
Set qry.Connection = con
Set result.Query = qry
qry.SQL = "SELECT * FROM Employees" 'use right table name from mdb here
result.Execute
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
result.AddRow
Call result.SetValue("EmployeeID",doc.EmployeeID(0))
Call result.SetValue("FirstName",doc.FirstName(0))
Call result.SetValue("LastName",doc.LastName(0))
Call result.SetValue("Department",doc.Department(0))
result.UpdateRow
Set doc = dc.GetNextDocument(doc)
Wend
result.Close(DB_CLOSE)
con.Disconnect
Else
Messagebox "No documents selected."
End If
End Sub
ASKER
Thank you for your help, but I was looking for VBA Excel code. My setup does not allow me to use Notes Agents. Hammer8
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What about pictures, attachments, embedded options ?
What are you really trying to do ?
I hope this helps !