récuprération pieces jointes

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

récuprération pieces jointes

Messagepar Biosset » 05 Juin 2003 à 08:58

Est-il possible lorque l'on reçoit un mail dûment identifié de détacher la pièce jointe pour la classer dans un répertoire , ceci automatiquement.Merci de votre aide
Biosset
 

Re: récuprération pieces jointes

Messagepar Raziel » 05 Juin 2003 à 10:40

Salut,Voici un code qui devrait répondre à ton pb. Je l'ai récupérer d'un autre code plus complexe. Conséquence, je n'ai pas pu le tester. Tu place ce code dans un agent qui s'exécute à chaque nouveau courrierFunction FileExist (Directory As String, FileName As String, Attribut As Integer) As IntegerOn Error Resume NextDim NomFichier As StringNomFichier = Dir$(Directory+FileName, Attribut)If NomFichier = "" Then FileExist = FalseElse FileExist = TrueEnd IfEnd FunctionSub DetachFile(Doc As notesdocument, FieldName As String, Directory As String, FileName As String)Dim rtitem As VariantSet rtitem = doc.GetFirstItem(FieldName)If (rtitem.Type = RICHTEXT) Then Forall Attachement In rtitem.EmbeddedObjects If (Attachement.Type = EMBED_ATTACHMENT) And Attachement.Name = FileName Then Call Attachement.ExtractFile (Directory+FileName) End If End ForallEnd IfEnd SubFunction OpenFile (PathFile As String, NameFile As String, OpenMode As String) As IntegerDim FileNum As IntegerDim FileName As StringFileNum% = Freefile()FileName = PathFile + NameFile' Ouverture du fichierSelect Case OpenModeCase "Output" Open FileName For Output As FileNum%Case "Append" Open FileName For Append As FileNum%Case "Input" Open FileName For Input As FileNum%End SelectOpenFile = FileNumEnd FunctionSub InitializeDim Session As New notessessionDim db As notesdatabaseDim DocCol As notesdocumentcollectionDim Doc As notesdocumentDim Indice As IntegerDim FileName As StringDim Directory As StringSet db = Session.currentdatabaseSet DocCol = db.UnprocessedDocumentsIf DocCol.count = 0 Then Exit SubDirectory = "\\toto\titi\" ' ce chemin doit être accessible par ton serveur Notes car l'agent va s'exécuter sur ton serveur Set Doc = DocCol.getfirstdocumentWhile Not Doc Is Nothing If Doc.hasitem("$FILE") Then ' On recherche tous les champs $FILE Forall Champ In Doc.Items If Champ.Name = "$FILE" Then For Indice = 0 To Ubound(Champ.Values) FileName = Champ.Values(Indice) ' On test si un fichier portant ce nom existe déjà If FileExist(Directory, FileName, 0) = False Then ' On créé la directory si elle n'existe pas If FileExist(Directory, "", 16) = False Then Mkdir Directory End If ' On détache le fichier Call DetachFile(Doc, "body", Directory, FileName) End If Next End If End Forall End If ' On marque le document comme traité Call Session.UpdateProcessedDoc(Doc) ' Passage au doc suivant Set Doc = DocCol.getnextdocument(Doc) WendEnd Sub
Raziel

L'administration est un lieu ou les gens qui arrivent en retard croisent dans l'escalier ceux qui partent en avance. [Georges Courteline]
Avatar de l’utilisateur
Raziel
Modérateur
Modérateur
 
Message(s) : 1795
Inscrit(e) le : 21 Déc 2004 à 11:06
Localisation : Roubaix


Retour vers Développement