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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| public objMail As Object
Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntryId As String
Dim intLength As Integer
intInitial = 1
intLength = Len(EntryIDCollection)
MsgBox "Collection of EntryIds: " & EntryIDCollection
intFinal = InStr(intInitial, EntryIDCollection, ",")
Do While intFinal <> 0
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intFinal - intInitial))
MsgBox "EntryId: " & strEntryId
Set objMail = Application.Session.GetItemFromID(strEntryId)
MsgBox objMail .Subject
CreationReunion
intInitial = intFinal + 1
intFinal = InStr(intInitial, EntryIDCollection, ",")
Loop
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intLength - intInitial) + 1)
MsgBox strEntryId
Set objMail = Application.Session.GetItemFromID(strEntryId)
MsgBox objMail .Subject
CreationReunion
End sub
Sub CreationReunion()
'---------------------------------------------------------------------------------------
' Procédure : CreationReunion
' Auteur : Dolphy35 - http://dolphy35.developpez.com/
' Date : Mai 2008
' Détail : Création d'une nouvelle entrée du calendrier + ajout du texte +
' ajout raccourci du mail + déplacer dans répertoire test à la racine
' de Boîte aux lettres.
'---------------------------------------------------------------------------------------
'Déclaration des objets
Dim objOutlook As Outlook.Application
Dim objReunion As Outlook.AppointmentItem
Dim objExplorer As Outlook.Explorer
' Dim objSelection As Outlook.Selection
' Dim objMail As Object
Dim strMail As String
Dim strSujet As String
Dim strDate As String
'Instance des Objets
Set objOutlook = Outlook.Application 'Instance de l'application
Set objExplorer = objOutlook.ActiveExplorer
' Set objSelection = objExplorer.Selection
Set objReunion = objOutlook.CreateItem(olAppointmentItem) 'Instance de la nouvelle entrée du calendrier
'Récupère les infos du mail reçu
With objMail
strMail = .SenderEmailAddress
strSujet = .Subject
strDate = .ReceivedTime
End With
'Déplacement du mail et création du raccourci
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Set myNameSpace = objOutlook.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox).Parent
Set myInbox = myNameSpace.Folder("Dossiers personnels")
Set myDestFolder = myInbox.Folders("sous dossier")
Myentryid = objMail.EntryID
Set objMail = objMail.Move(myDestFolder)
'définition de la réunion
With objReunion
.MeetingStatus = olMeeting
.Subject = strSujet
.Location = "Mon Bureau"
.Recipients.Add (strMail)
.Body = "-selon votre demande du " + strDate + "." + Chr(13) + Chr(13) + "Voici comment traiter ce mail:" + Chr(13) + "-ouvrez ce mail avec Outlook ou https://webmail.heig-vd.ch" + Chr(13) + "-cliquez sur les boutons Accepter/Refuser/etc qui apparaissent en haut à gauche du mail selon votre disponibilité" + Chr(13) + "" + Chr(13) + ""
.Attachments.Add objMail, olOLE, , objMail.Subject
.Display
End With
'Vide des instances
Set objOutlook = Nothing
Set objReunion = Nothing
Set objExplorer = Nothing
' Set objSelection = Nothing
End Sub |
Partager