You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.Net.Mail/MailAddress.xml
+63-79Lines changed: 63 additions & 79 deletions
Original file line number
Diff line number
Diff line change
@@ -51,26 +51,25 @@
51
51
<remarks>
52
52
<formattype="text/markdown"><, [host name](xref:System.Net.Mail.MailAddress.Host), and an optional [display name](xref:System.Net.Mail.MailAddress.DisplayName). <xref:System.Net.Mail.MailAddress.DisplayName> can contain non-ASCII characters if you encode them.
58
57
59
58
The <xref:System.Net.Mail.MailAddress> class supports the following mail address formats:
60
59
61
-
- A simple address format of `user@host`. If a <xref:System.Net.Mail.MailAddress.DisplayName%2A> is not set, this is the mail address format generated.
62
-
- A standard quoted display name format of `"display name" <user@host>`. If a <xref:System.Net.Mail.MailAddress.DisplayName%2A> is set, this is the format generated.
60
+
- A simple address format of `user@host`. If a <xref:System.Net.Mail.MailAddress.DisplayName> is not set, this is the mail address format that's generated.
61
+
- A standard quoted display name format of `"display name" <user@host>`. If a <xref:System.Net.Mail.MailAddress.DisplayName> is set, this is the format that's generated.
63
62
64
-
- Angle brackets are added around the <xref:System.Net.Mail.MailAddress.User%2A> name and <xref:System.Net.Mail.MailAddress.Host%2A> name, if these are not included. For example, `"display name" user@host` is changed to `"display name" <user@host>`.
65
-
- Quotes are added around the <xref:System.Net.Mail.MailAddress.DisplayName%2A>, if these are not included. For example, `display name <user@host>` is changed to `"display name" <user@host>`.
66
-
- Unicode characters are supported in the <xref:System.Net.Mail.MailAddress.DisplayName%2A> property.
63
+
- If they're not already included, angle brackets are added around the <xref:System.Net.Mail.MailAddress.User> name and <xref:System.Net.Mail.MailAddress.Host> name. For example, `"display name" user@host` is changed to `"display name" <user@host>`.
64
+
- If they're not already included, quotes are added around the <xref:System.Net.Mail.MailAddress.DisplayName>. For example, `display name <user@host>` is changed to `"display name" <user@host>`.
65
+
- Unicode characters are supported in the <xref:System.Net.Mail.MailAddress.DisplayName> property.
67
66
68
67
Within these two formats, the following elements are allowed:
69
68
70
-
- A <xref:System.Net.Mail.MailAddress.User%2A> name with quotes. For example, `"user name"@host`.
71
-
- Consecutive and trailing dots in user names. For example, `user...name..@host`.
69
+
- A <xref:System.Net.Mail.MailAddress.User> name with quotes. For example, `"user name"@host`.
72
70
- Bracketed domain literals. For example, `<user@[my domain]>`.
73
71
- Comments. For example, `(comment)"display name"(comment)<(comment)user(comment)@(comment)domain(comment)>(comment)`. Comments are removed before transmission.
72
+
- .NET 9 and earlier ONLY: Consecutive and trailing dots in user names. For example, `user...name..@host`. (Starting in .NET 10, consecutive dots aren't allowed.)
74
73
75
74
A comma is used to separate elements in a list of mail addresses. As a result, a comma should not be used in unquoted display names in a list. The following mail addresses would be allowed:
76
75
@@ -90,19 +89,21 @@ The following mail address would not be allowed:
90
89
91
90
`"John "Jr" Doe" <user@host>`
92
91
93
-
When the username is not quoted, all text between the start of the string (or comma) and the address are considered part of the <xref:System.Net.Mail.MailAddress.DisplayName%2A>, including comments. For example:
92
+
When the username is not quoted, all text between the start of the string (or comma) and the address is considered part of the <xref:System.Net.Mail.MailAddress.DisplayName>, including comments. For example:
94
93
95
94
`(non comment) unquoted display (non comment) name (non comment) <user@host>`
96
95
97
-
Although the <xref:System.Net.Mail.MailAddress> class accepts a mail address as valid, other mail servers may not accept the mail address.
96
+
Although the <xref:System.Net.Mail.MailAddress> class accepts a mail address as valid, other mail servers might not accept the mail address.
98
97
99
98
The <xref:System.Net.Mail.MailAddress> class does not support the following mail address formats:
100
99
101
100
- Mixed quoted and unquoted display names. For example, `display "name" <user@host>`.
102
101
- Groups, as defined in RFC 2822 Section 3.4 published by the IETF.
103
102
- The obsolete user name formats of `"user"."name"@host`, `user."name"@host` or `"user".name@host`.
103
+
- .NET 10 and later versions only: Consecutive dots in the user name, for example, `[email protected]`.
104
104
105
105
## Examples
106
+
106
107
The following code example demonstrates sending an email message by using the <xref:System.Net.Mail.SmtpClient>, <xref:System.Net.Mail.MailAddress>, and <xref:System.Net.Mail.MailMessage> classes.
The following code example uses this constructor to create a <xref:System.Net.Mail.MailAddress> object for the <xref:System.Net.Mail.MailMessage.Bcc%2A> recipient of an email message.
The following code example uses this constructor to create a <xref:System.Net.Mail.MailAddress> object for the <xref:System.Net.Mail.MailMessage.Bcc> recipient of an email message.
@@ -256,19 +255,17 @@ The following code example demonstrates sending an email message by using the <x
256
255
<remarks>
257
256
<formattype="text/markdown"><.
263
-
264
-
If `address` contains a display name, and `displayName` is not `null` and is not equal to <xref:System.String.Empty?displayProperty=nameWithType>, `displayName` overrides the value specified in `address`.
258
+
Leading and trailing white space in the display name is preserved.
265
259
260
+
If `displayName` contains non-ASCII characters, the iso-8859-1 character set is used for the `displayName` encoding. Encoding non-ASCII characters is discussed in RFC 1522, which is available at [https://www.ietf.org/](https://www.ietf.org/).
266
261
262
+
If `address` contains a display name, and `displayName` is not `null` and is not equal to <xref:System.String.Empty?displayProperty=nameWithType>, `displayName` overrides the value specified in `address`.
267
263
268
264
## Examples
269
-
The following code example uses this constructor to create <xref:System.Net.Mail.MailAddress> instances for the sender and recipient of an email message.
The following code example uses this constructor to create <xref:System.Net.Mail.MailAddress> instances for the sender and recipient of an email message.
@@ -336,22 +333,20 @@ The following code example demonstrates sending an email message by using the <x
336
333
<remarks>
337
334
<formattype="text/markdown"><![CDATA[
338
335
339
-
## Remarks
340
-
Leading and trailing white space in the display name is preserved.
336
+
Leading and trailing white space in the display name is preserved.
341
337
342
-
If `address` contains a display name, and `displayName` is not `null` and is not equal to <xref:System.String.Empty?displayProperty=nameWithType>, `displayName` overrides the value specified in `address`.
343
-
344
-
The <xref:System.Net.Mail.MailAddress.%23ctor%2A> method does not check if the `displayName` parameter is valid. This method removes surrounding quotes not displayed by the <xref:System.Net.Mail.MailAddress.DisplayName%2A> property. Quotes will be added before transmission, except where <xref:System.Text.Encoding.ASCII%2A> or <xref:System.Text.Encoding.Unicode%2A> is specified in the `displayNameEncoding` parameter. The encoding specified in the `displayNameEncoding` parameter will be applied to the <xref:System.Net.Mail.MailAddress.DisplayName%2A> property before transmission <xref:System.Text.Encoding.ASCII%2A> or <xref:System.Text.Encoding.Unicode%2A> is specified in the `displayNameEncoding` parameter. <xref:System.Text.Encoding.UTF8%2A> is the default encoding if none is specified.
345
-
346
-
For more information on supported mail address formats, see <xref:System.Net.Mail.MailAddress>.
338
+
If `address` contains a display name, and `displayName` is not `null` and is not equal to <xref:System.String.Empty?displayProperty=nameWithType>, `displayName` overrides the value specified in `address`.
347
339
340
+
The <xref:System.Net.Mail.MailAddress.%23ctor(System.String,System.String,System.Text.Encoding)> constructor does not check if the `displayName` parameter is valid. This method removes surrounding quotes not displayed by the <xref:System.Net.Mail.MailAddress.DisplayName> property. Quotes will be added before transmission, except where <xref:System.Text.Encoding.ASCII> or <xref:System.Text.Encoding.Unicode> is specified in the `displayNameEncoding` parameter. The encoding specified in the `displayNameEncoding` parameter will be applied to the <xref:System.Net.Mail.MailAddress.DisplayName> property before transmission <xref:System.Text.Encoding.ASCII> or <xref:System.Text.Encoding.Unicode> is specified in the `displayNameEncoding` parameter. <xref:System.Text.Encoding.UTF8> is the default encoding if none is specified.
348
341
342
+
For more information on supported mail address formats, see <xref:System.Net.Mail.MailAddress>.
349
343
350
344
## Examples
351
-
The following code example uses this constructor to create <xref:System.Net.Mail.MailAddress> instances for the sender of an email message.
@@ -475,17 +468,15 @@ The following code example demonstrates sending an email message by using the <x
475
468
<remarks>
476
469
<formattype="text/markdown"><![CDATA[
477
470
478
-
## Remarks
479
-
Display names that contain non-ASCII characters are returned in human-readable form. Use the <xref:System.Net.Mail.MailAddress.ToString%2A> method to get the encoded form of the <xref:System.Net.Mail.MailAddress.DisplayName%2A>.
480
-
481
-
Some software programs that are used to read email display the <xref:System.Net.Mail.MailAddress.DisplayName%2A> property value instead of, or in addition to, the email address.
482
-
471
+
Display names that contain non-ASCII characters are returned in human-readable form. Use the <xref:System.Net.Mail.MailAddress.ToString> method to get the encoded form of the <xref:System.Net.Mail.MailAddress.DisplayName>.
483
472
473
+
Some software programs that are used to read email display the <xref:System.Net.Mail.MailAddress.DisplayName> property value instead of, or in addition to, the email address.
484
474
485
475
## Examples
486
-
The following code example displays the <xref:System.Net.Mail.MailAddress.DisplayName%2A> for the recipient of an email message.
@@ -585,8 +576,7 @@ The following code example demonstrates sending an email message by using the <x
585
576
<remarks>
586
577
<formattype="text/markdown"><![CDATA[
587
578
588
-
## Remarks
589
-
The <xref:System.Net.Mail.MailAddress.GetHashCode%2A> method returns a hash code of the mail address. This value can be used as a key in hash tables.
579
+
The <xref:System.Net.Mail.MailAddress.GetHashCode> method returns a hash code of the mail address. This value can be used as a key in hash tables.
590
580
591
581
]]></format>
592
582
</remarks>
@@ -638,15 +628,13 @@ The following code example demonstrates sending an email message by using the <x
638
628
<remarks>
639
629
<formattype="text/markdown"><![CDATA[
640
630
641
-
## Remarks
642
-
In a typical email address, the host string includes all information following the "`@`" sign. For example, in `"[email protected]"`, the host is `"contoso.com"`.
643
-
644
-
631
+
In a typical email address, the host string includes all information following the "`@`" sign. For example, in `"[email protected]"`, the host is `"contoso.com"`.
645
632
646
633
## Examples
647
-
The following code example displays the destination of an email message.
@@ -693,19 +681,17 @@ The following code example demonstrates sending an email message by using the <x
693
681
<remarks>
694
682
<formattype="text/markdown"><![CDATA[
695
683
696
-
## Remarks
697
-
The string returned by this method is not necessarily identical to the string specified when the instance was created. If the <xref:System.Net.Mail.MailAddress.DisplayName%2A> property is not `null` and not equal to <xref:System.String.Empty?displayProperty=nameWithType> (""), <xref:System.Net.Mail.MailAddress.ToString%2A> returns a string composed using the following syntax:
If <xref:System.Net.Mail.MailAddress.DisplayName%2A> is `null` or is equal to <xref:System.String.Empty?displayProperty=nameWithType>, <xref:System.Net.Mail.MailAddress.ToString%2A> returns the value of the <xref:System.Net.Mail.MailAddress.Address%2A> property.
684
+
The string returned by this method is not necessarily identical to the string specified when the instance was created. If the <xref:System.Net.Mail.MailAddress.DisplayName> property is not `null` and not equal to <xref:System.String.Empty?displayProperty=nameWithType> (""), <xref:System.Net.Mail.MailAddress.ToString> returns a string composed using the following syntax:
If <xref:System.Net.Mail.MailAddress.DisplayName> is `null` or is equal to <xref:System.String.Empty?displayProperty=nameWithType>, <xref:System.Net.Mail.MailAddress.ToString> returns the value of the <xref:System.Net.Mail.MailAddress.Address> property.
704
689
705
690
## Examples
706
-
The following code example displays the destination of an email message.
@@ -916,15 +902,13 @@ The following code example demonstrates sending an email message by using the <x
916
902
<remarks>
917
903
<formattype="text/markdown"><![CDATA[
918
904
919
-
## Remarks
920
-
In a typical email address, the user string includes all information preceding the "`@`" sign. For example, in `"[email protected]"`, the user is `"tsmith"`.
921
-
922
-
905
+
In a typical email address, the user string includes all information preceding the "`@`" sign. For example, in `"[email protected]"`, the user is `"tsmith"`.
923
906
924
907
## Examples
925
-
The following code example displays the destination of an email message.
0 commit comments