Wie zum download-Anhänge aus lotus notes mit vb-script

Ich habe einen code die downloads, die Anlage von lotus notes. Das problem ist, dass jedes mal, wenn er läuft lädt er alle Anhaftung. Wie kann ich den Zustand nicht laden Sie die zuvor heruntergeladene Anhänge?

Option Explicit
Sub Save_Attachments_Remove_Emails()

Const stPath As String = "c:\Attachments\"
Const EMBED_ATTACHMENT As Long = 1454
Const RICHTEXT As Long = 1

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("CAT-DH-23.apd.cat.com/Servers/Caterpillar", "mail\pamsmine.nsf")
' Please use this Open Function if the server is not referenced and GETDATABASE
' opens the db file if the file is in local system.
'Call noDatabase.Open("", "C:\notes\test.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

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
  • Wie würden Sie wissen, wenn eine Anlage bereits heruntergeladen wurde oder nicht? Es gibt keine flags, die in einer Notes-mail-Datenbank angeben, wenn das angehängte Dokument heruntergeladen wurde. Eine Möglichkeit wäre zu testen, ob die Datei bereits existiert, aber das hätte Fehler für unterschiedlichen Dateien mit dem gleichen Namen, an verschiedenen e-mails. Eine andere Möglichkeit wäre, erstellen Sie einen Ordner für jede E-Mail enthält Anhänge.
  • Können wir nicht markieren Sie die verarbeiteten E-mail als gelesen. Und dann nur noch die ungelesenen E-mails verarbeitet werden. Es ist nur eine Idee. Bitte vorschlagen, wenn dies möglich ist? Auch darauf, wie können wir dieses Skript ausführen 24/7.
  • Und ein weiterer Punkt @CST-Link , es wird keine Datei mit dem gleichen Namen. Jetzt bitte vorschlagen, wie kann ich das erreichen?
  • Hinzugefügt eine Antwort, hat es funktioniert für Sie?
  • Überprüfen heute und sicherlich lassen Sie wissen,...
InformationsquelleAutor user3859736 | 2014-07-22
Schreibe einen Kommentar