Automatisch attachments opslaan in emails in Lotus Notes

Status
Niet open voor verdere reacties.

MrTinkertrain

Gebruiker
Lid geworden
4 sep 2005
Berichten
79
Hallo VBA-experts,

Voor Outlook is er online volop code te vinden om via VBA Outlook te kunnen manipuleren.
Voor Lotus Notes is er in dat opzicht vrij weinig te vinden.
Ik heb ooit eens de volgende code gevonden :

Code:
Option Explicit
 
Const stPath As String = "c:\Attachments\"
Const EMBED_ATTACHMENT As Long = 1454

Const RICHTEXT As Long = 1
 
Sub Save_Attachments_Remove_Emails()
  Dim noSession As Object
  Dim noDatabase As Object
  Dim noView As Object
  Dim noDocument As Object
  Dim noRemoveDocument As Object
  Dim noNextDocument As Object
 
  'Embedded objects are of the datatype Variant.
  Dim vaItem As Variant
  Dim vaAttachment As Variant
 
  'Instantiate the Notes session.
  Set noSession = CreateObject("Notes.NotesSession")
 
  'Instantiate the actual Notes database.
  '(Here is the personal e-mail database used and since it's a
  'local database no reference is made to any server.)
  Set noDatabase = noSession.GETDATABASE("", "mail\xldennis.nsf")
 
  'Folders are views in Lotus Notes and in this example the Inbox
  'is used.
  Set noView = noDatabase.GetView("($Inbox)")
 
  'Get the first document in the defined view.
  Set noDocument = noView.GetFirstDocument
 
  'Iterate through all the e-mails in the view Inbox.
  Do Until noDocument Is Nothing
    Set noNextDocument = noView.GetNextDocument(noDocument)
    'Check if the document has an attachment or not.
    If noDocument.HasEmbedded Then
      Set vaItem = noDocument.GetFirstItem("Body")
      If vaItem.Type = RICHTEXT Then
        For Each vaAttachment In vaItem.EmbeddedObjects
          If vaAttachment.Type = EMBED_ATTACHMENT Then
            'Save the attached file into the new folder.
            vaAttachment.ExtractFile stPath & vaAttachment.Name
            'Set the e-mail object which will be deleted.
            Set noRemoveDocument = noDocument
          End If
        Next vaAttachment
      End If
    End If
    Set noDocument = noNextDocument
    'Delete the e-mails which have an attached file.
    If Not noRemoveDocument Is Nothing Then
      noRemoveDocument.Remove (True)
      Set noRemoveDocument = Nothing
    End If
  Loop
 
  'Release objects from memory.
  Set noRemoveDocument = Nothing
  Set noNextDocument = Nothing
  Set noDocument = Nothing
  Set noView = Nothing
  Set noDatabase = Nothing
  Set noSession = Nothing
 
  MsgBox "All the attachments in the Inbox have successfully been saved" & vbCrLf & _
         "and the associated e-mails have successfully been deleted.", vbInformation
 
End Sub

Deze code checkt de Inbox in Lotus Notes, slaat gevonden attachments op in een map op de harde schijf en verwijdert vervolgens het betreffende email-bericht.

Nu vroeg ik mij af of het mogelijk is om de code zodanig aan te passen, dat e.e.a. uitsluitend wordt uitgevoerd, indien er een bepaald woord in het onderwerp voorkomt.
Ik ben een n00b waar het aankomt op het zelf toevoegen van code aan reeds bestaande code, dus ik kom er zelf niet uit.
Is er iemand die mij hierin zou kunnen helpen ?

Ik ga ervan uit dat bovenstaande code daadwerkelijk doet wat ik heb aangegeven.
Omdat ik graag slechts bepaalde emails met bijlages uit mijn Inbox zou willen verwijderen, heb ik het niet aangedurfd om bovenstaande code te testen (uit angst om bepaalde emails kwijt te raken die ik niet kwijt MAG raken)

Weet iemand raad ?

Bij voorbaat dank !
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan