>> Das Verhalten bezieht sich auf das Notizfeld des Kontakts.
Aha, jetzt wird es eindeutig - die Variable Item ist bei dir ein ContactItem.
Um das Verhalten bei mir zu reproduzieren, habe ich mir einen Kontakt erstellt und diesem die von dir genannte Notiz hinzugefügt.
Ich suche dann nach dem Kontakt und ändere dort Inhalt der Notiz - so wie du es tust - nur das ich vorher die nicht gewünschten Informationen entferne (diese "HYPERLINK"-Ausdrücke). Das Entfernen findet mit einem regulären Ausdruck statt.
Interessant für dich ist also vorallem die Hilfsfunktion ContactNoteBody und die Stelle in MyTest in der sie aufgerufen wird.
Option Explicit
Public Sub MyTest()
Dim objCI As Outlook.ContactItem
Dim strUser As String
strUser = "Der Peiniger (alias Chef)"
' nach einem bestimmten Kontakt suchen
With GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Set objCI = .Items.Find("[FirstName] = 'Maxi' AND [LastName] = 'Maus'")
End With
' wenn Kontakt nicht gefunden wurde -> Ende
If objCI Is Nothing Then
Call MsgBox("Kontakt nicht gefunden", vbExclamation)
Exit Sub
End If
With objCI
' Notiz des Kontakts ändern
.Body = ContactNoteBody(objCI) & vbNewLine & _
Format$(Date, "yyyy-mm-dd") & " Daten Aktualisiert " & strUser & ": " & vbNewLine
' Änderung speichern
.Save
End With
Set objCI = Nothing
End Sub
' Hilfsfunktion
Private Function ContactNoteBody(Contact As Outlook.ContactItem) As String
Dim objRegExp As Object
On Error Resume Next
Set objRegExp = CreateObject("VBScript.RegExp")
On Error GoTo 0
If objRegExp Is Nothing Then
ContactNoteBody = Contact.Body
Else
With objRegExp
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "\bHYPERLINK\s+"".+""\s+(.+)\b"
ContactNoteBody = .Replace(Contact.Body, "$1")
End With
Set objRegExp = Nothing
End If
End Function
Hoffe das hilft weiter.
Gruß
|