Class MailHeaderCollection
A case-insensitive collection of MailHeader objects parsed from a
message's transport headers (PidTagTransportMessageHeaders). Header names
are matched using OrdinalIgnoreCase.
Inherited Members
Namespace: DRIT.Mail.Mapi
Assembly: DRIT.Mail.dll
Syntax
public sealed class MailHeaderCollection : IEnumerable<MailHeader>, IEnumerable
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Constructors
View SourceMailHeaderCollection()
Initializes a new empty instance of the MailHeaderCollection class.
Declaration
public MailHeaderCollection()
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Properties
View SourceCount
Gets the number of headers in the collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
this[int]
Gets the value of the header at the specified index.
Declaration
public string? this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Property Value
| Type | Description |
|---|---|
| string |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
this[string]
Gets the first header with the specified name, or null if not found. The lookup is case-insensitive.
Declaration
public MailHeader? this[string name] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Property Value
| Type | Description |
|---|---|
| MailHeader |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Methods
View SourceAdd(MailHeader)
Adds a copy of the specified header to the collection.
Declaration
public void Add(MailHeader header)
Parameters
| Type | Name | Description |
|---|---|---|
| MailHeader | header | The header to add. |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Add(string, string)
Adds a header to the collection.
Declaration
public void Add(string name, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name. |
| string | value | The header value. |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Clear()
Removes all headers from the collection.
Declaration
public void Clear()
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Contains(string)
Determines whether a header with the specified name exists.
Declaration
public bool Contains(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name to locate. |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
GetAll(string)
Gets all headers with the specified name.
Declaration
public IReadOnlyList<MailHeader> GetAll(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name to locate. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<MailHeader> |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
GetDecodedValue(string)
Gets the RFC 2047 decoded value of the first header with the specified name, or null.
Declaration
public string? GetDecodedValue(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name to locate. |
Returns
| Type | Description |
|---|---|
| string |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<MailHeader> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<MailHeader> |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
GetValue(string)
Gets the raw value of the first header with the specified name, or null.
Declaration
public string? GetValue(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name to locate. |
Returns
| Type | Description |
|---|---|
| string |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Remove(string)
Removes all headers with the specified name.
Declaration
public void Remove(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name to remove. |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).
Set(string, string)
Replaces all headers with the specified name with a single header.
Declaration
public void Set(string name, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header field name. |
| string | value | The header value. |
Remarks
When created through TransportMessageHeaders the collection is a live view: any mutation (Add(string, string), Remove(string), Value setter) writes the rebuilt header block back to TransportMessageHeaders.
Header folding (RFC 5322 §2.2.3) is unfolded on parse; RFC 2047 encoded words are preserved in Value and exposed decoded through DecodedValue / GetDecodedValue(string).