or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

account-auth.mdadvanced.mdattachments.mdcalendar.mdcontacts.mddatetime.mdfolders.mdindex.mdmessages.mdsearch.mdtasks.md

contacts.mddocs/

0

# Contacts and Distribution Lists

1

2

Contact management functionality for creating, updating, and organizing contact information. Includes support for distribution lists and contact groups.

3

4

## Capabilities

5

6

### Contact Management

7

8

```python { .api }

9

class Contact:

10

def __init__(self, account: Account = None, folder: Folder = None, **kwargs):

11

"""Create a new contact."""

12

13

# Personal information

14

display_name: str

15

given_name: str

16

middle_name: str

17

surname: str

18

nickname: str

19

title: str

20

generation: str

21

22

# Contact details

23

email_addresses: list[EmailAddress]

24

phone_numbers: list[PhoneNumber]

25

physical_addresses: list[PhysicalAddress]

26

im_addresses: list[str]

27

28

# Business information

29

company_name: str

30

department: str

31

job_title: str

32

manager: str

33

assistant_name: str

34

office_location: str

35

36

# Personal details

37

birthday: EWSDate

38

wedding_anniversary: EWSDate

39

spouse_name: str

40

children: list[str]

41

42

def save(self, update_fields: list = None):

43

"""Save the contact."""

44

45

def delete(self, delete_type: str = 'MoveToDeletedItems'):

46

"""Delete the contact."""

47

```

48

49

### Distribution Lists

50

51

```python { .api }

52

class DistributionList:

53

def __init__(self, account: Account = None, folder: Folder = None, **kwargs):

54

"""Create a distribution list."""

55

56

display_name: str

57

file_as: str

58

members: list[Member]

59

60

def expand(self) -> list[Mailbox]:

61

"""Expand distribution list to get all members."""

62

63

def save(self, update_fields: list = None):

64

"""Save the distribution list."""

65

66

def delete(self, delete_type: str = 'MoveToDeletedItems'):

67

"""Delete the distribution list."""

68

```

69

70

### Contact Properties

71

72

```python { .api }

73

class EmailAddress:

74

def __init__(self, email: str, label: str = 'EmailAddress1'):

75

"""Contact email address."""

76

77

email: str

78

label: str

79

name: str

80

81

class PhoneNumber:

82

def __init__(self, phone_number: str, label: str = 'PrimaryPhone'):

83

"""Contact phone number."""

84

85

phone_number: str

86

label: str

87

88

class PhysicalAddress:

89

def __init__(self, label: str = 'Home', **kwargs):

90

"""Contact physical address."""

91

92

label: str

93

street: str

94

city: str

95

state: str

96

country_or_region: str

97

postal_code: str

98

```

99

100

Usage example:

101

102

```python

103

from exchangelib import Contact, EmailAddress, PhoneNumber, PhysicalAddress

104

105

contact = Contact(

106

account=account,

107

folder=account.contacts,

108

display_name='John Smith',

109

given_name='John',

110

surname='Smith',

111

company_name='Example Corp',

112

job_title='Software Engineer',

113

email_addresses=[

114

EmailAddress(email='john.smith@company.com', label='EmailAddress1'),

115

EmailAddress(email='john@personal.com', label='EmailAddress2')

116

],

117

phone_numbers=[

118

PhoneNumber(phone_number='+1-555-123-4567', label='BusinessPhone'),

119

PhoneNumber(phone_number='+1-555-987-6543', label='MobilePhone')

120

]

121

)

122

123

contact.save()

124

```