17[UnsupportedOSPlatform(
"browser")]
87 if (
value.Length == 0)
231 _transport.EnableSsl =
value;
287 [MemberNotNull(
"_transport")]
288 [MemberNotNull(
"_onSendCompletedDelegate")]
289 [MemberNotNull(
"_clientDomain")]
324 foreach (
char c
in text)
328 stringBuilder.Append(c);
331 if (stringBuilder.Length > 0)
352 credentials = defaultNetworkCredentials;
354 transport.Credentials = credentials;
383 string path = $
"{Guid.NewGuid()}.eml";
393 this.SendCompleted?.Invoke(
this, e);
401 public void Send(
string from,
string recipients,
string? subject,
string? body)
436 if (message.
From ==
null)
440 if (message.
To !=
null)
444 mailAddressCollection.
Add(
item);
447 if (message.
Bcc !=
null)
451 mailAddressCollection.
Add(item2);
454 if (message.
CC !=
null)
458 mailAddressCollection.
Add(item3);
461 if (mailAddressCollection.
Count == 0)
465 _transport.IdentityRequired =
false;
533 public void SendAsync(
string from,
string recipients,
string? subject,
string? body,
object? userToken)
563 if (message.
From ==
null)
567 if (message.
To !=
null)
574 if (message.
Bcc !=
null)
581 if (message.
CC !=
null)
611 message.
Send(
_writer, sendEnvelope:
true, allowUnicode);
711 ((
SmtpClient)sender).SendCompleted -= handler;
764 if (_port <= 0 || _port > 65535)
830 smtpClient.InCall =
false;
831 smtpClient._failedRecipientException =
null;
904 message.Sender?.GetSmtpAddress(allowUnicode);
905 message.From.GetSmtpAddress(allowUnicode);
927 protected virtual void Dispose(
bool disposing)
static AsyncOperation CreateOperation(object? userSuppliedState)
object? UserSuppliedState
void PostOperationCompleted(SendOrPostCallback d, object? arg)
static void SuppressFinalize(object obj)
string GetAscii(string unicode)
static bool Exists([NotNullWhen(true)] string? path)
static string Combine(string path1, string path2)
static bool IsPathRooted([NotNullWhen(true)] string? path)
static NetworkCredential DefaultNetworkCredentials
void InvokeCallback(object result)
void Add(string addresses)
string GetSmtpAddress(bool allowUnicode)
void EndSend(IAsyncResult asyncResult)
MailAddressCollection Bcc
void Send(BaseWriter writer, bool sendEnvelope, bool allowUnicode)
string BuildDeliveryStatusNotificationString()
IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, bool allowUnicode, AsyncCallback callback, object state)
SmtpFailedRecipientException GetFailedRecipientException()
string? PickupDirectoryLocation
string _pickupDirectoryLocation
Task SendMailAsync(MailMessage message, CancellationToken cancellationToken)
SendCompletedEventHandler? SendCompleted
virtual void Dispose(bool disposing)
SendOrPostCallback _onSendCompletedDelegate
SmtpDeliveryFormat DeliveryFormat
void SendCompletedWaitCallback(object operationState)
void Send(string from, string recipients, string? subject, string? body)
bool _useDefaultCredentials
bool IsUnicodeSupported()
void UpdateTransportCredentials()
SmtpDeliveryMethod DeliveryMethod
void Complete(Exception exception, IAsyncResult result)
void SendAsync(string from, string recipients, string? subject, string? body, object? userToken)
void ValidateUnicodeRequirement(MailMessage message, MailAddressCollection recipients, bool allowUnicode)
void Send(MailMessage message)
SmtpDeliveryMethod _deliveryMethod
void ConnectCallback(IAsyncResult result)
MailWriter GetFileMailWriter(string pickupDirectory)
X509CertificateCollection ClientCertificates
void OnSendCompleted(AsyncCompletedEventArgs e)
SmtpDeliveryFormat _deliveryFormat
System.Net.ContextAwareResult _operationCompletedResult
Task SendMailAsync(MailMessage message)
bool UseDefaultCredentials
bool IsSystemNetworkCredentialInCache(CredentialCache cache)
ICredentialsByHost _customCredentials
static void ContextSafeCompleteCallback(IAsyncResult ar)
static readonly AsyncCallback s_contextSafeCompleteCallback
Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken)
Task SendMailAsync(string from, string recipients, string? subject, string? body)
SmtpFailedRecipientException _failedRecipientException
SmtpClient(string? host, int port)
void SendMailCallback(IAsyncResult result)
ServicePoint _servicePoint
MailAddressCollection _recipients
void SendAsync(MailMessage message, object? userToken)
void SendMessageCallback(IAsyncResult result)
void TimeOutCallback(object state)
ICredentialsByHost? Credentials
ICredentialsByHost Credentials
MailWriter SendMail(MailAddress sender, MailAddressCollection recipients, string deliveryNotify, bool allowUnicode, out SmtpFailedRecipientException exception)
void EndGetConnection(IAsyncResult result)
IAsyncResult BeginGetConnection(System.Net.ContextAwareResult outerResult, AsyncCallback callback, object state, string host, int port)
MailWriter EndSendMail(IAsyncResult result)
X509CertificateCollection ClientCertificates
IAsyncResult BeginSendMail(MailAddress sender, MailAddressCollection recipients, string deliveryNotify, bool allowUnicode, AsyncCallback callback, object state)
void GetConnection(string host, int port)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static void Associate(object first, object second, [CallerMemberName] string memberName=null)
static ServicePoint FindServicePoint(Uri address)
static string SmtpNeedAbsolutePickupDirectory
static string InvalidPort
static string net_inasync
static string UnspecifiedHost
static string SmtpGetIisPickupDirectoryNotSupported
static string SmtpFromRequired
static string net_timeout
static string SmtpSendMailFailure
static string SmtpRecipientRequired
static string SmtpInvalidOperationDuringSend
static string net_emptystringset
static string SmtpPickupDirectoryDoesnotSupportSsl
static int Exchange(ref int location1, int value)
bool TrySetException(Exception exception)
static Task FromCanceled(CancellationToken cancellationToken)
bool Dispose(WaitHandle notifyObject)
delegate void SendCompletedEventHandler(object sender, AsyncCompletedEventArgs e)