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
|
Option Base 0
Sub SaveAttachement(Item As Outlook.MailItem)
Dim TabPath(2) As String, SavePath As String
Set attachs = Item.Attachments
TabPath(0) = "\\toto\"
TabPath(1) = "\\tata\"
'Tableau de direction des PJ____________________________________________
If (Item.Sender = "labretagnecavousgagne@finistere.bzh") Then
SavePath = TabPath(0)
ElseIf (Item.Sender = "ilnepleutjamais@finistere.bzh") Then
SavePath = TabPath(1)
Call SaveMyMail(Item, TabPath(1))
End If
'_______________________________________________________________________
For Each attach In attachs
file = attach.FileName
attach.SaveAsFile SavePath & file
Next
End Sub
Sub SaveMyMail(MyMail As Outlook.MailItem, SavePath As String)
Dim Sujet As String
Sujet = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(MyMail.Subject, "\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "<", ""), ">", ""), "|", ""), ".", ""), """", ""), vbTab, ""), Chr(7), "")
MyMail.SaveAs SavePath & Sujet & ".msg", OlSaveAsType.olMSG
End Sub |
Partager