Das Notes Forum
Lotus Notes / Domino Sonstiges => Tools & Downloads => Thema gestartet von: Claus am 17.04.02 - 16:11:39
-
Hallo zusammen !
Ich suche ein Tool mit dem ich nach dem Maileingang automatisch die Attachements herauslösen und speichern kann, und dann anschließend ein Programm (z.B. EXCEL) aufrufe. Darf auch ruhig etwas kosten.
Danke
Claus
-
Hilft dir das weiter?
http://www.atnotes.de/cgi-bin/yabb/YaBB.pl?board=002-3;action=display;num=1013353024
-
Danke, aber leider erfüllt das nicht den Zweck den ich brauche. Es sollte so arbeiten wie das Tool CASAVEIT, welches unter Outlook verwendet werden kann.
-
Nun ja, mit ein bisschen Script programmierung ist das möglich. Schliesslich arbeiten wir mit Notes 8)und da braucht man i.d.R kein Zusatztool, wenn mal eine Funktionalität fehlt. 8)
hier mal die Lösung meines amerikanischen Kollegen
Hier ist zwar der Pfad statisch,; das läßt sich aber leicht ändern.
by Brad Pitt ( der heißt wirklich so ;D )
The following code will allow your users to more effectively manage their attachments. We have found that in our organization, most of the used disk space in mail files is due to attachments that users have forgotten to delete in their mail file. This code will make it a lot easier for them by allowing them to go to an attachments view, which displays only messages with attachments (obviously) and allows them to select any number of messages and click a button to delete all attachments from the messages.
You can customize the location where the attachments are stored, I chose c:\My Documents\Notes Attachments
If a user downloads a file that already exists in that directory, it will ask them if they want to overwrite the file, create a new file name with a number appended to the filename (dismore.txt will be called dismore1.txt, if they download it again it will be called dismore2.txt), or cancel the entire operation.
In place of the attachments in the message, it tells them where the file was downloaded to and what the file was called.
Rich Text: Create a view called "Attachments". This view is catagorized by date and shows who sent the attachment, the subject of the message, and a column with the following formula - @AttachmentNames + "=" + @Text(@Round(@AttachmentLengths/1024)) + " Kb\'s" + " "
I also have a total MB column set to total with the following formula - @Sum(@Round(@AttachmentLengths/1024000))
Create an action button in this view that calls the following agent..... I called the agent (Download Attachments). The code for the action button is as follows:
answer := @Prompt([YESNO]; "Download selected attachments?"; "Would you like to download all attachments from the selected documents to the c:\\My Documents\\Notes Attachments\\ directory on your computer?");
@If(answer = 1; @Command([ToolsRunMacro];"(Download Attachments)"); @Return(""))
The agent is setup like the following:
---Initialize Event---
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dc As NotesDocumentCollection
Dim answer As Integer
Dim rtitem As Variant
Dim attachname As String
Dim filename As String
Dim extension As String
Dim checkname As String
Dim newname As String
Dim x As Integer
On Error Resume Next
Mkdir "c:\My Documents"
Mkdir "c:\My Documents\Notes Attachments"
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
x = 0
Do Until Doc Is Nothing
Set rtitem = doc.GetFirstItem( "Body" )
' Goes to the body field and finds all attachments
If ( rtitem.Type = RICHTEXT ) Then
Forall obj In rtitem.EmbeddedObjects
If ( obj.Type = EMBED_ATTACHMENT ) Then
' If a duplicate file name is found, ask the user whether they would like to overwrite , update name, or cancel entire operation
If( Dir$("c:\My Documents\Notes Attachments\" & obj.Source)) <> "" Then
attachname = obj.source
answer = Msgbox ("This folder already contains a file named " & attachname & ". " & Chr(10) & "Would you like to create a new file name for this file in the format 'filenameX'? " & Chr(10) & Chr(10) & "If you choose yes, a new file name will be created. " & Chr(10) & "If you choose no, the file will be overwritten with this attachment. " & Chr(10) & "The cancel button will stop the download process for the rest of the selected documents." , 547, "Warning!" )
' 2= cancel, 7= No (overwrite), 6= Yes (update name)
Else
attachname = obj.source
Call obj.ExtractFile( "c:\My Documents\Notes Attachments\" & attachname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to c:\My Documents\Notes Attachments\ as filename: " ) & attachname)
Call doc.Save( False, True )
answer = 0
End If
If( answer = 2 ) Then ' User has chosen to cancel
Exit Sub
End If
If( answer = 7 ) Then ' User has chosen to overwrite existing file
' Downloads file name and overwrites the attachment with the same name
Call obj.ExtractFile( "c:\My Documents\Notes Attachments\" & attachname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to c:\My Documents\Notes Attachments\ as filename: " ) & attachname)
Call doc.Save( False, True )
answer = 0
End If
If( answer = 6 ) Then ' User has chosen to download with new name
' Gets everything to the left and right of the file name and puts them in variables
filename = sLeft( attachname, "." )
extension = "." & sRight( attachname, "." )
newname = attachname
' Loop until you find unique file name - Dir command returns "" if file name is not found in specified directoty
Do While (Dir$("c:\My Documents\Notes Attachments\" & newname)) <> ""
' Adds next sequential number to the end of the file name - then puts them all together as newname
x=x+1
newname = filename & Cstr(x) & extension
Loop
' Once you have unique file name - download with new name
Call obj.ExtractFile( "c:\My Documents\Notes Attachments\" & newname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to c:\My Documents\Notes Attachments\ as filename: " ) & newname)
Call doc.Save( False, True )
answer = 0
End If
End If
End Forall
End If
answer = 0
Set doc = dc.GetNextDocument(doc)
Loop
End Sub
Create this functions in the agent:
----sLeft-----
Function sLeft ( sourceString As String, searchString As String ) As String
pos% = Instr ( sourceString, searchString )
If pos% > 0 Then pos% = pos% -1
sLeft = Left ( sourceString, pos%)
End Function
----sRight-----
Function sRight ( sourceString As String, searchString As String) As String
pos% = Instr ( sourceString, searchString )
length% = Len ( sourceString )
start% = length% - pos%
sRight = Right ( sourceString, start% )
End Function
-
könnte man den Hinweis auf die Datei auch so
anpassen, das dieser die Datei mit der Anwendung, beim Anklicken, öffnet ?
Die DAU's finden die ja nicht wieder, selbst wenn der Pfad da steht. ;D
Hardy
-
Ja, du müsstest einen Hotspot in das Doc einfügen
file://c:\temp\meineDatei.xyz
-
Is klar, aber wie geht das mit LotusScript bezogen
auf den Code ?
Hardy
-
JAAAAA, das ist das grosse Geheimnis. Ehrlich gesagt, ich weiss es nicht. Habe schon mal bei Notes.net geschaut, aber da weiss auch keiner Bescheid. :-X
Ich habe momentan auch keine grosse Lust, mich durch die Lotus Notes API zu wühlen :P
Was mir noch so als Möglichkeit vorschwebt, ist per script einen button in das Dokument zu kopieren ( AppendRTItem) der den Code aus meiner Reattach.nsf enthält. Die Ablageorte für das/die Attachments kann man dann in ein verstecktes Feld schreiben. der Code liest das Feld und baut ein PopUp auf, aus dem der User das Attachment auswählen kann, das er starten will.
Wenn ich dazu komme, mache ich das mal übers WE
eknori
-
Wäre "EmbedObject method" nicht eine Möglichkeit
als object link ?
Hardy
-
So, Wochenende vorbei. Hab's fertig:
Von wegen API und so ein Schnick Schnack; einfach mal ein bisschen rumprobiert und schon gehts
Man kann ja automatisch einen Hotspot erstellen, wenn man im RT Feld eingibt
http://www.undsoweiterde....
wenn man dann im Lesemodus das Dokument öffnet, kann man den Link anklicken und die Seite wird aufgerufen.
Analog kann man das ja auch mit File:// machen... hatte ich gadacht. Aber dann stand nur der Text im Feld.
Hätte ich doch nur vorher mal statt // einfach \\ eingegeben :-[ :-[
Hier also der komplette Code noch einmal in der richtigen Fassung.
Der Pfad zum Abspeichern darf KEINE Leerzeichen enthalten. Und, bei mir wird immer erst der Netscape Navigator gestartet. Ist möglicherweise eine Systemeinstellung.
So, viel Spass beim Probieren
euer eknori
'Download Attachments:
Option Public
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dc As NotesDocumentCollection
Dim answer As Integer
Dim rtitem As Variant
Dim attachname As String
Dim filename As String
Dim extension As String
Dim checkname As String
Dim newname As String
Dim x As Integer
On Error Resume Next
Mkdir "c:\temp"
' Mkdir "c:\My Documents\Notes Attachments"
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
x = 0
Do Until Doc Is Nothing
Set rtitem = doc.GetFirstItem( "Body" )
' Goes to the body field and finds all attachments
If ( rtitem.Type = RICHTEXT ) Then
Forall obj In rtitem.EmbeddedObjects
If ( obj.Type = EMBED_ATTACHMENT ) Then
' If a duplicate file name is found, ask the user whether they would like to overwrite , update name, or cancel entire operation
If( Dir$("c:\temp\" & obj.Source)) <> "" Then
attachname = obj.source
answer = Msgbox ("This folder already contains a file named " & attachname & ". " & Chr(10) & "Would you like to create a new file name for this file in the format 'filenameX'? " & Chr(10) & Chr(10) & "If you choose yes, a new file name will be created. " & Chr(10) & "If you choose no, the file will be overwritten with this attachment. " & Chr(10) & "The cancel button will stop the download process for the rest of the selected documents." , 547, "Warning!" )
' 2= cancel, 7= No (overwrite), 6= Yes (update name)
Else
attachname = obj.source
Call obj.ExtractFile( "c:\temp\" & attachname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & attachname)
Call doc.Save( False, True )
answer = 0
End If
If( answer = 2 ) Then ' User has chosen to cancel
Exit Sub
End If
If( answer = 7 ) Then ' User has chosen to overwrite existing file
' Downloads file name and overwrites the attachment with the same name
Call obj.ExtractFile( "c:\temp\" & attachname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & attachname)
Call doc.Save( False, True )
answer = 0
End If
If( answer = 6 ) Then ' User has chosen to download with new name
' Gets everything to the left and right of the file name and puts them in variables
filename = sLeft( attachname, "." )
extension = "." & sRight( attachname, "." )
newname = attachname
' Loop until you find unique file name - Dir command returns "" if file name is not found in specified directoty
Do While (Dir$("c:\temp\" & newname)) <> ""
' Adds next sequential number to the end of the file name - then puts them all together as newname
x=x+1
newname = filename & Cstr(x) & extension
Loop
' Once you have unique file name - download with new name
Call obj.ExtractFile( "c:\temp\" & newname )
Call obj.Remove
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & newname)
Call doc.Save( False, True )
answer = 0
End If
End If
End Forall
End If
answer = 0
Set doc = dc.GetNextDocument(doc)
Loop
End Sub
Function sLeft ( sourceString As String, searchString As String ) As String
pos% = Instr ( sourceString, searchString )
If pos% > 0 Then pos% = pos% -1
sLeft = Left ( sourceString, pos%)
End Function
Function sRight ( sourceString As String, searchString As String) As String
pos% = Instr ( sourceString, searchString )
length% = Len ( sourceString )
start% = length% - pos%
sRight = Right ( sourceString, start% )
End Function
-
So, noch ein kleiner Nachschlag:
Wenn man die Spaces im Pfad durch "+" ( ohne die " ) oder durch "%20" ersetzt ( ReplaceSubstring), dann geht es auch mit solchen Pfadangaben
-
Das war aber ein kurzes Wochenende !
Bei mir wird immer der Explorer geöffnet.
Wahrscheinlich sieht Notes das als WEB-Adresse an.
Soweit aber Superklasse ;D
Hardy