![]() |
| Le forum de référence en programmation et développement. Articles, cours et tutoriels du débutant au chef de projet et DBA confirmé. | |||||||
|
|||||||
![]() |
|
|
Outils de la discussion |
|
|
#1 (permalink) |
|
Futur Membre du Club
![]() Date d'inscription: février 2008
Messages: 31
|
Bonjour,
j'utilise ce code ( qui n'est pas de moi) pour enregistrer les pièces jointes reçues dans Outlook 2007; il fonctionne bien; je l'ai même intégré dans une règle (script reconnu en remplaçant Sub par Function). Code :
Sub PJ() Const olFolderInbox = 6 Set objoutlook = CreateObject("Outlook.Application") Set objNamespace = objoutlook.GetNamespace("MAPI") Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) Set colItems = objFolder.Items For Each objMessage In colItems intCount = objMessage.Attachments.Count If intCount > 0 Then For i = 1 To intCount objMessage.Attachments.Item(i).SaveAsFile "F:\Photos\réception\" & _ objMessage.Attachments.Item(i).FileName Next End If Next End Sub Dernière modification par sanfric ; 03/11/2008 à 16h49 |
|
|
|
|
|
#2 (permalink) |
|
Membre expérimenté
![]() Date d'inscription: mars 2006
Localisation: Tourcoing
Âge: 37
Messages: 530
|
Salut,
Voici une solution : Code :
Sub PJ() Const olFolderInbox = 6 Set objoutlook = CreateObject("Outlook.Application") Set objNamespace = objoutlook.GetNamespace("MAPI") Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) Set colItems = objFolder.Items For Each objMessage In colItems intCount = objMessage.Attachments.Count If intCount > 0 Then For i = 1 To intCount if UCASE(right(objMessage.Attachments.Item(i).FileName;3))="JPG" then objMessage.Attachments.Item(i).SaveAsFile "F:\Photos\réception\" & _ objMessage.Attachments.Item(i).FileName end if Next End If Next End Sub
__________________
Meilleurs voeux 2009 Have a nice day. ![]() Oliv' OUI à l'utilisation, NON au « copillage » Merci de citer la source |
|
|
|
|
|
#3 (permalink) |
|
Futur Membre du Club
![]() Date d'inscription: février 2008
Messages: 31
|
Bonjour,
Il y avait une petite erreur de syntaxe dans le code précédent. Cela fonctionne avec le code suivant. Code :
If UCase(Right(objMessage.Attachments.Item(i).FileName, 3)) = "JPG" Then Code :
Function PJ (strID As Outlook.MailItem) Set objoutlook = CreateObject("Outlook.Application") Set objNamespace = objoutlook.GetNamespace("MAPI") Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox) Set colItems = objFolder.Items For Each objMessage In colItems intCount = objMessage.Attachments.Count If intCount > 0 Then For i = 1 To intCount Rem enregistrement sélectif If UCase(Right(objMessage.Attachments.Item(i).FileName, 3)) = "JPG" Then objMessage.Attachments.Item(i).SaveAsFile "F:\Photos\réception\" & _ objMessage.Attachments.Item(i).FileName End If If UCase(Right(objMessage.Attachments.Item(i).FileName, 3)) = "DOC" Then objMessage.Attachments.Item(i).SaveAsFile "F:\TEXTPHO\" & _ objMessage.Attachments.Item(i).FileName End If Next End If Next End Function Merci à Oliv pour ses suggestions
|
|
|
|
|
![]() |
![]() |
||
enregistrement sélectif des PJ
|
||
| Outils de la discussion | |
|
|