Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get sender email address from document

Status
Not open for further replies.

HaydenMB

IS-IT--Management
May 30, 2003
24
GB
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 suppose you mean that some From addresses are not supposed to have their attachments saved.

In this case, you would need to make a list of the addresses that are not to be touched, and compare with the sender (from field).

If you use a profile document to list the email addresses in question, you can open it before cycling through the docs in the view and compare the From address to the notesitem content.

Could you voice your opinion of this method before we go into coding issues ?

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top