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
| Function BrowseForFolder(Title As String) As String
Dim objShell As Object
Dim ssfWINDOWS As Long
Dim objFolder As Object
ssfWINDOWS = 36
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, Title, 0, ssfWINDOWS)
If (Not objFolder Is Nothing) Then
BrowseForFolder = objFolder.self.Path & "\"
'Add code here
End If
Set objFolder = Nothing
Set objShell = Nothing
End Function
Sub sav_mail_as_msg(repertoire As String, Optional objCurrentMessage As Object)
If objCurrentMessage Is Nothing Then Set objCurrentMessage = ActiveInspector.CurrentItem
NomExport = Format$(objCurrentMessage.ReceivedTime, "yymmdd") & " - " & objCurrentMessage.SenderName & " - " & objCurrentMessage.Subject
PathNomExport = repertoire & Left(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace( _
NomExport, "\", ""), "/", ""), ":", ""), "*", ""), "?", ""), "<", ""), ">", ""), "|", ""), ".", ""), """", ""), vbTab, ""), Chr(7), ""), 160) & ".msg"
n = 1
MemPath = PathNomExport
While Dir(PathNomExport) <> ""
PathNomExport = Left(MemPath, Len(MemPath) - 4) & "(" & n & ")" & ".msg"
n = n + 1
Wend
objCurrentMessage.SaveAs PathNomExport, OlSaveAsType.olMSG
End Sub
Sub Save()
Dim MonOutlook As Outlook.Application
Dim LeMail As Object
Dim LesMails As Outlook.Selection
Dim repertoire As String
Set MonOutlook = Outlook.Application
Set LesMails = MonOutlook.ActiveExplorer.Selection
repertoire = BrowseForFolder("Choisissez la destination")
For Each LeMail In LesMails
Call sav_mail_as_msg(repertoire, LeMail)
Next LeMail
Set LesMails = Nothing
MsgBox "Fin de traitement"
End Sub |
Partager