Class VCard
A vCard (RFC 6350, RFC 2426, informal 2.1). Immutable after parsing. Construct via VCardBuilder for writing.
Inherited Members
Namespace: DRIT.Mail.Rfc.VCard
Assembly: DRIT.Mail.dll
Syntax
public sealed class VCard
Constructors
View SourceVCard(VCardVersion, string?, VCardName?, IReadOnlyList<string>, byte[]?, string?, DateTime?, IReadOnlyList<VCardAddress>, IReadOnlyList<VCardPhoneNumber>, IReadOnlyList<VCardEmail>, string?, VCardGeo?, string?, string?, string?, IReadOnlyList<string>, string?, string?, DateTimeOffset?, string?, string?, VCardClassification?, IReadOnlyList<VCardProperty>, IReadOnlyList<VCardProperty>)
Initializes a new instance of the VCard class.
Declaration
public VCard(VCardVersion version, string? formattedName, VCardName? name, IReadOnlyList<string> nicknames, byte[]? photo, string? photoMediaType, DateTime? birthday, IReadOnlyList<VCardAddress> addresses, IReadOnlyList<VCardPhoneNumber> phoneNumbers, IReadOnlyList<VCardEmail> emails, string? timeZone, VCardGeo? geo, string? title, string? role, string? organization, IReadOnlyList<string> categories, string? note, string? productId, DateTimeOffset? revision, string? uid, string? url, VCardClassification? classification, IReadOnlyList<VCardProperty> extendedProperties, IReadOnlyList<VCardProperty> allProperties)
Parameters
| Type | Name | Description |
|---|---|---|
| VCardVersion | version | |
| string | formattedName | |
| VCardName | name | |
| IReadOnlyList<string> | nicknames | |
| byte[] | photo | |
| string | photoMediaType | |
| DateTime? | birthday | |
| IReadOnlyList<VCardAddress> | addresses | |
| IReadOnlyList<VCardPhoneNumber> | phoneNumbers | |
| IReadOnlyList<VCardEmail> | emails | |
| string | timeZone | |
| VCardGeo | geo | |
| string | title | |
| string | role | |
| string | organization | |
| IReadOnlyList<string> | categories | |
| string | note | |
| string | productId | |
| DateTimeOffset? | revision | |
| string | uid | |
| string | url | |
| VCardClassification? | classification | |
| IReadOnlyList<VCardProperty> | extendedProperties | |
| IReadOnlyList<VCardProperty> | allProperties |
Properties
View SourceAddresses
Gets the delivery addresses (ADR). May be empty.
Declaration
public IReadOnlyList<VCardAddress> Addresses { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<VCardAddress> |
AllProperties
Gets all raw properties in source order, including those covered by the typed accessors. Use this for round-tripping or for properties not in the typed model.
Declaration
public IReadOnlyList<VCardProperty> AllProperties { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<VCardProperty> |
Birthday
Gets the birthday (BDAY), or null if not specified.
Declaration
public DateTime? Birthday { get; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
Categories
Gets the categories (CATEGORIES). May be empty.
Declaration
public IReadOnlyList<string> Categories { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Classification
Gets the classification (CLASS), or null if not specified.
Declaration
public VCardClassification? Classification { get; }
Property Value
| Type | Description |
|---|---|
| VCardClassification? |
Emails
Gets the email addresses (EMAIL). May be empty.
Declaration
public IReadOnlyList<VCardEmail> Emails { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<VCardEmail> |
ExtendedProperties
Gets the X-* extension properties. May be empty.
Declaration
public IReadOnlyList<VCardProperty> ExtendedProperties { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<VCardProperty> |
FormattedName
Gets the formatted display name (FN), or null if not specified.
Declaration
public string? FormattedName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Geo
Gets the geographic position (GEO), or null if not specified.
Declaration
public VCardGeo? Geo { get; }
Property Value
| Type | Description |
|---|---|
| VCardGeo |
Name
Gets the structured name (N), or null if not specified.
Declaration
public VCardName? Name { get; }
Property Value
| Type | Description |
|---|---|
| VCardName |
Nicknames
Gets the nicknames (NICKNAME). May be empty.
Declaration
public IReadOnlyList<string> Nicknames { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Note
Gets the note (NOTE), or null if not specified.
Declaration
public string? Note { get; }
Property Value
| Type | Description |
|---|---|
| string |
Organization
Gets the organization (ORG), or null if not specified.
Declaration
public string? Organization { get; }
Property Value
| Type | Description |
|---|---|
| string |
PhoneNumbers
Gets the telephone numbers (TEL). May be empty.
Declaration
public IReadOnlyList<VCardPhoneNumber> PhoneNumbers { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<VCardPhoneNumber> |
Photo
Gets the photo data (PHOTO), or null if not specified.
Declaration
public byte[]? Photo { get; }
Property Value
| Type | Description |
|---|---|
| byte[] |
PhotoMediaType
Gets the photo media type (e.g. image/jpeg), or null if not specified.
Declaration
public string? PhotoMediaType { get; }
Property Value
| Type | Description |
|---|---|
| string |
ProductId
Gets the product identifier (PRODID), or null if not specified.
Declaration
public string? ProductId { get; }
Property Value
| Type | Description |
|---|---|
| string |
Revision
Gets the last revision timestamp (REV), or null if not specified.
Declaration
public DateTimeOffset? Revision { get; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset? |
Role
Gets the business role (ROLE), or null if not specified.
Declaration
public string? Role { get; }
Property Value
| Type | Description |
|---|---|
| string |
TimeZone
Gets the timezone (TZ), or null if not specified.
Declaration
public string? TimeZone { get; }
Property Value
| Type | Description |
|---|---|
| string |
Title
Gets the job title (TITLE), or null if not specified.
Declaration
public string? Title { get; }
Property Value
| Type | Description |
|---|---|
| string |
Uid
Gets the unique identifier (UID), or null if not specified.
Declaration
public string? Uid { get; }
Property Value
| Type | Description |
|---|---|
| string |
Url
Gets the URL, or null if not specified.
Declaration
public string? Url { get; }
Property Value
| Type | Description |
|---|---|
| string |
Version
Gets the vCard version.
Declaration
public VCardVersion Version { get; }
Property Value
| Type | Description |
|---|---|
| VCardVersion |
Methods
View SourceLoad(Stream)
Loads a single VCard from the specified stream. If the stream contains multiple vCards, the first is returned.
Declaration
public static VCard Load(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
Returns
| Type | Description |
|---|---|
| VCard |
Load(string)
Loads a single VCard from the specified file. If the file contains multiple vCards, the first is returned.
Declaration
public static VCard Load(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file or path to process. |
Returns
| Type | Description |
|---|---|
| VCard |
LoadAll(Stream)
Loads all vCards from the specified stream.
Declaration
public static IReadOnlyList<VCard> LoadAll(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<VCard> |
LoadAll(string)
Loads all vCards from the specified file.
Declaration
public static IReadOnlyList<VCard> LoadAll(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file or path to process. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<VCard> |
Write(Stream, VCardVersion?)
Writes this vCard to the specified stream.
Declaration
public void Write(Stream stream, VCardVersion? version = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The destination stream. |
| VCardVersion? | version | The version to write. If null, the version of this vCard is used. |
Write(string, VCardVersion?)
Writes this vCard to the specified file.
Declaration
public void Write(string fileName, VCardVersion? version = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The destination file name. |
| VCardVersion? | version | The version to write. If null, the version of this vCard is used. |