J'utilise le script BlueDevilFan VBA pour afficher les en-têtes Internet d'un e-mail dans Outlook 2013. J'ai essayé de modifier la VBA de sorte qu'il ne sort que le « à » ou « pour » adresse et rejette tout autre texte,Comment extraire l'adresse 'for'/'to' de l'en-tête dans Outlook 2007+ en utilisant VBA Script
est Ci-dessous le script VBA:
Sub ViewInternetHeader()
Dim olItem As Outlook.MailItem, olMsg As Outlook.MailItem
Dim strheader As String
For Each olItem In Application.ActiveExplorer.Selection
strheader = GetInetHeaders(olItem)
Set olMsg = Application.CreateItem(olMailItem)
With olMsg
.BodyFormat = olFormatPlain
.Body = strheader
.Display
End With
Next
Set olMsg = Nothing
End Sub
Function GetInetHeaders(olkMsg As Outlook.MailItem) As String
' Purpose: Returns the internet headers of a message.'
' Written: 4/28/2009'
' Author: BlueDevilFan'
' http://techniclee.wordpress.com/
' Outlook: 2007'
Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
Dim olkPA As Outlook.PropertyAccessor
Set olkPA = olkMsg.PropertyAccessor
GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
Set olkPA = Nothing
End Function
J'ai essayé quelque chose comme je voudrais utiliser dans le mot à trouver et supprimer un certain contenu, mais ne peut pas le faire fonctionner dans Outlook!
Sub CleanUp()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(\To: """)"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
.Text = "(\To: """)"
.Execute Replace:=wdReplaceAll
End With
End With
End Sub
Cela ne veut pas travailler, jette erreur sur « variable bloc non définie » en ligne: olMsg.Body = olMsg.To & Chr (13) & olMsg.Sender – nickrenwick
@nickrenwick Correction, l'expéditeur et à venir de olItem – Sorceri