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
| Public monBrouillon As Outlook.MailItem
Sub TrouveLeBrouillon()
'---------------------------------------------------------------------------------------
' Procedure : TrouveLeBrouillon
' Author : OLIV-
' Date : 05/02/2015
' Purpose : trouver le brouillon à parti d'un Email ouvert
'---------------------------------------------------------------------------------------
'
Dim oConv As Outlook.Conversation
Dim oTable As Outlook.table
Dim oRow As Outlook.Row
Dim oMail As Outlook.MailItem
Dim oItem As Outlook.MailItem
Const PR_STORE_ENTRYID As String = _
"http://schemas.microsoft.com/mapi/proptag/0x0FFB0102"
On Error Resume Next
' Obtain the current item for the active inspector.
Set oMail = Application.ActiveInspector.CurrentItem
Dim FolderBrouillons As Folder
Set FolderBrouillons = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
If Not (oMail Is Nothing) Then
' Obtain the Conversation object.
Set oConv = oMail.GetConversation
If Not (oConv Is Nothing) Then
Set oTable = oConv.GetTable
oTable.Columns.add (PR_STORE_ENTRYID)
Do Until oTable.EndOfTable
Set oRow = oTable.GetNextRow
' Use EntryID and StoreID to open the item.
Set oItem = Application.Session.GetItemFromID( _
oRow("EntryID"), _
oRow.BinaryToString(PR_STORE_ENTRYID))
Debug.Print oItem.CreationTime, oItem.ConversationID, oItem.ConversationIndex
If oItem.Parent.FullFolderPath = FolderBrouillons.FolderPath Then
Set monBrouillon = oMail
'Stop
'Exit Sub
End If
Loop
End If
End If
End Sub |
Partager