ContactItem.AddPicture-Methode (Outlook)

Fügt ein Bild zu einem Kontaktelement hinzu.

Syntax

Ausdruck. AddPicture( _Path_ )

Ausdruck Eine Variable, die ein ContactItem-Objekt darstellt.

Parameter

Name Erforderlich/Optional Datentyp Beschreibung
Path Erforderlich String Eine Zeichenfolge, die den vollständigen Pfad und dateinamen des Bilds enthält, das dem Kontaktelement hinzugefügt werden soll.

HinwBemerkungeneise

Wenn bereits ein Bild mit dem Kontaktelement verknüpft ist, überschreibt diese Methode das vorhandene Bild.

Bei dem Bild kann es sich um ein Symbol oder eine Datei im GIF-, JPEG-, BMP-, TIFF-, WMF-, EMF- oder PNG-Format handeln. Microsoft Outlook ändert die Größe des Bildes automatisch nach Bedarf.

Beispiel

Im folgenden Beispiel für Microsoft Visual Basic for Applications (VBA) wird der Benutzer aufgefordert, den Namen eines Kontakts und den Dateinamen anzugeben, der ein Bild des Kontakts enthält. Anschließend wird das Bild dem Kontaktelement hinzugefügt. Wenn bereits ein Bild für das Kontaktelement vorhanden ist, fordert das Beispiel den Benutzer auf, anzugeben, ob das vorhandene Bild durch die neue Datei überschrieben werden soll.

Sub AddPictureToAContact() 
 
 Dim myNms As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myContactItem As Outlook.ContactItem 
 
 Dim strName As String 
 
 Dim strPath As String 
 
 Dim strPrompt As String 
 
 
 
 Set myNms = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNms.GetDefaultFolder(olFolderContacts) 
 
 strName = InputBox("Type the name of the contact: ") 
 
 Set myContactItem = myFolder.Items(strName) 
 
 If myContactItem.HasPicture = True Then 
 
 strPrompt = MsgBox("The contact already has a picture associated with it. Do you want to overwrite the existing picture?", vbYesNo) 
 
 If strPrompt = vbNo Then 
 
 Exit Sub 
 
 End If 
 
 End If 
 
 strPath = InputBox("Type the file name for the contact: ") 
 
 myContactItem.AddPicture (strPath) 
 
 myContactItem.Save 
 
 myContactItem.Display 
 
 End Sub

Siehe auch

ContactItem-Objekt

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.