Hi,
I have the following code from VBA that loops through all documents in a mail database and extracts all the attachments from them.
The only problem is I have to make sure that I do not detacth any files that have a certain email address.
Does anybody know how I can extract the email address from the document?
Here is what i have...
Dim NotesDoc As New NotesDocument
Dim rtItem As NotesItem
Dim rtItem1 As NotesItem
Dim NotesObject As Variant
Dim NotesDB As New NotesDatabase
Dim s As NotesSession
Dim NotesColl As New NotesDocumentCollection
Dim doc As NotesDocument
Dim strFile As String
Dim nHandle As Variant
Dim FromName As New NotesName
Sub sTest()
[green]'Initialize session and set componants[/green]
Set s = CreateObject("Lotus.NotesSession")
s.Initialize
Set NotesDB = s.GetDatabase(conServer, conDbase)
Set NotesColl = NotesDB.AllDocuments
Set doc = NotesColl.GetFirstDocument
[green]'Loop through documents[/green]
While Not (doc Is Nothing)
[green]'UniversalID to be stored in table so that ever detatched again[/green]
Debug.Print doc.UniversalID
Set rtItem = doc.GetFirstItem("Body")
If rtItem.Type = RICHTEXT Then
[green]'Create the notes object as the attchment[/green]
Set NotesObject = rtItem.GetEmbeddedObject("*.xls")
[green]'Loop through the objects detatching them as it loops through[/green]
For Each NotesObject In rtItem.EmbeddedObjects
If NotesObject.Type = EMBED_ATTACHMENT Then
[green] 'Extract the attachment to Local Drive[/green]
Call NotesObject.ExtractFile("D:\LMS Net Track\Imports\Advice Notes\" & NotesObject.Name)
Debug.Print doc.Authors
strFile = NotesObject.Name
[green]'Attachment Name[/green]
Debug.Print strFile
End If
Next
End If
[green] 'Get the next document[/green]
Set doc = NotesColl.GetNextDocument(doc)
Wend
End Sub
Thanks
Hayden
I have the following code from VBA that loops through all documents in a mail database and extracts all the attachments from them.
The only problem is I have to make sure that I do not detacth any files that have a certain email address.
Does anybody know how I can extract the email address from the document?
Here is what i have...
Dim NotesDoc As New NotesDocument
Dim rtItem As NotesItem
Dim rtItem1 As NotesItem
Dim NotesObject As Variant
Dim NotesDB As New NotesDatabase
Dim s As NotesSession
Dim NotesColl As New NotesDocumentCollection
Dim doc As NotesDocument
Dim strFile As String
Dim nHandle As Variant
Dim FromName As New NotesName
Sub sTest()
[green]'Initialize session and set componants[/green]
Set s = CreateObject("Lotus.NotesSession")
s.Initialize
Set NotesDB = s.GetDatabase(conServer, conDbase)
Set NotesColl = NotesDB.AllDocuments
Set doc = NotesColl.GetFirstDocument
[green]'Loop through documents[/green]
While Not (doc Is Nothing)
[green]'UniversalID to be stored in table so that ever detatched again[/green]
Debug.Print doc.UniversalID
Set rtItem = doc.GetFirstItem("Body")
If rtItem.Type = RICHTEXT Then
[green]'Create the notes object as the attchment[/green]
Set NotesObject = rtItem.GetEmbeddedObject("*.xls")
[green]'Loop through the objects detatching them as it loops through[/green]
For Each NotesObject In rtItem.EmbeddedObjects
If NotesObject.Type = EMBED_ATTACHMENT Then
[green] 'Extract the attachment to Local Drive[/green]
Call NotesObject.ExtractFile("D:\LMS Net Track\Imports\Advice Notes\" & NotesObject.Name)
Debug.Print doc.Authors
strFile = NotesObject.Name
[green]'Attachment Name[/green]
Debug.Print strFile
End If
Next
End If
[green] 'Get the next document[/green]
Set doc = NotesColl.GetNextDocument(doc)
Wend
End Sub
Thanks
Hayden