Bonjour
Je voudrais créer un agent qui va enregistrer la piece jointe du mail que j'ai selectionné dans une vue.
Avez-vous une idée de la manière de coder cet agent
Merci
Dim Session As NotesSession
Dim UIWork As NotesUIWorkspace
Dim db As NotesDatabase
Dim Collection As NotesDocumentCollection
Dim Doc As NotesDocument
Dim vrValue As Variant
On Error GoTo CatchError
Set Session = New NotesSession
Set db = session.Currentdatabase
Set Collection = db.Unprocesseddocuments
If Collection Is Nothing Then
Exit Sub
ElseIf collection.Count = 0 Then
Exit sub
End If
Set UIWork = New NotesUIWorkspace
vrValue = UIwork.SaveFileDialog(True," Select directory",,"C:\")
Set Doc = Collection.Getfirstdocument()
While Not doc Is Nothing
Call FileDetachAll(Doc, "",vrValue(0),"")
Set Doc= Collection.Getnextdocument(Doc)
Wend
Set Collection = nothing
Exit Sub
CatchError:
MsgBox "("+Cstr(GetThreadInfo (1))+" Call by "+Cstr(GetThreadInfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + CStr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Exit SubFunction FileDetachAll(wDoc As notesdocument, Byval wChamp As String,wDirectory As String, Byval wnbPath As Boolean, Byval wnbDelete As Boolean, wnbSave As Boolean)As Variant
Dim rtitem As NotesRichTextItem
Dim lstValue List As String
Dim i As Integer
Dim vrEO As Variant
On Error Goto CatchError
lstValue(0) = ""
If wDoc Is Nothing Then
Error 9999,"wDoc is Nothing"
Else
If wDoc.HasEmbedded = False Then
FileDetachAll = lstValue
Erase lstValue
Exit Function
End If
End If
If Trim(wChamp) = "" Then
Error 9999,"wChamp empty"
Exit Function
Else
Set rtitem = wDoc.GetFirstItem(wChamp)
If rtitem Is Nothing Then
Error 9999,"rtitem => ''"+wChamp+"'' is nothing"
Exit Function
Else
If (rtitem.Type <> RICHTEXT) Then
Error 9999,"'"+wChamp+"'' is not NotesRichTextItem"
Exit Function
End If
End If
End If
If Trim(wDirectory) = "" Then
Error 9999,"wDirectory empty"
Exit Function
Else
If Right(Trim(wDirectory),1)<>"\" Then
wDirectory = Trim(wDirectory)+"\"
Else
wDirectory = Trim(wDirectory)
End If
End If
i=0
If Trim(wChamp) = "" Then
vrEO = wDoc.EmbeddedObjects
Else
vrEO = rtitem.EmbeddedObjects
End If
If testVariant(vrEO) = True Then
Forall Attachement In vrEO
If Attachement.Type = EMBED_ATTACHMENT Then
Call Attachement.ExtractFile(wDirectory+Trim(Attachement.Name))
If wnbPath = True Then
lstValue(i) = wDirectory+Attachement.Name
Else
lstValue(i) = Attachement.Name
End If
i=i+1
If wnbDelete = True Then
Call Attachement.Remove
End If
End If
End Forall
vrEO = Null
End If
Set rtitem = Nothing
If wnbSave = True Then
Call wDoc.Save(True,False)
End If
FileDetachAll = lstValue
Erase lstValue
Exit Function
CatchError:
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Set rtitem = Nothing
lstValue(0) = "ERROR"
FileDetachAll = lstValue
Erase lstValue
Exit Function
End Function