1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Dim WithEvents colSentItems As Items
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If MsgBox("Souhaitez-vous archiver l'email que vous venez d'envoyer?", vbQuestion + vbYesNo, "confirmation") = vbNo Then Exit Sub
Dim objFolder As Outlook.Folder
Set objFolder = Application.Session.GetDefaultFolder(olFolderSentMail).Folders("Archivage")
Set Item.SaveSentMessageFolder = objFolder
Item.Save
End Sub
Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
'#########################################################
Set colSentItems = NS.GetDefaultFolder(olFolderSentMail).Folders("Archivage").Items
'#########################################################
End Sub
Private Sub colSentItems_ItemAdd(ByVal Item As Object)
'By Oliv ' janv 2008 pour Outlook 2003 feat. Sue Mosher
'http://www.outlookcode.com/codedetail.aspx?id=456
If Item.Class = olMail Then
Strname = Repertoire & Left(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Item.Subject, "\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "<", ""), ">", ""), "|", ""), ".", ""), """", ""), vbTab, ""), Chr(7), ""), 160)
Item.Display
Dim objInsp
Dim colCB
Dim objCBB
On Error Resume Next
Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars
Set objCBB = colCB.FindControl(, 748) 'enregistrer sous
If Not objCBB Is Nothing Then
objCBB.Execute
End If
Item.Close olDiscard
End If
End Sub
Function remplaceCaracteresInterdit(ByVal CheminStr As String)
Dim objCurrentMessage As Outlook.MailItem
Dim liste As Variant
Dim L
liste = Array("\", "/", ":", "*", "?", "<", ">", "|", ".", """", vbTab, Chr(7))
For L = 0 To UBound(liste)
CheminStr = Replace(CheminStr, liste(L), "")
Next L
remplaceCaracteresInterdit = CheminStr
'MsgBox CheminStr
End Function |
Partager