Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Send() [1/2]

void System.Net.Mail.SmtpClient.Send ( MailMessage message)
inline

Definition at line 411 of file SmtpClient.cs.

412 {
413 if (_disposed)
414 {
415 throw new ObjectDisposedException(GetType().FullName);
416 }
417 if (System.Net.NetEventSource.Log.IsEnabled())
418 {
419 System.Net.NetEventSource.Info(this, $"DeliveryMethod={DeliveryMethod}", "Send");
420 System.Net.NetEventSource.Associate(this, message, "Send");
421 }
422 SmtpFailedRecipientException exception = null;
423 if (InCall)
424 {
426 }
427 if (message == null)
428 {
429 throw new ArgumentNullException("message");
430 }
431 if (DeliveryMethod == SmtpDeliveryMethod.Network)
432 {
434 }
435 MailAddressCollection mailAddressCollection = new MailAddressCollection();
436 if (message.From == null)
437 {
439 }
440 if (message.To != null)
441 {
442 foreach (MailAddress item in message.To)
443 {
444 mailAddressCollection.Add(item);
445 }
446 }
447 if (message.Bcc != null)
448 {
449 foreach (MailAddress item2 in message.Bcc)
450 {
451 mailAddressCollection.Add(item2);
452 }
453 }
454 if (message.CC != null)
455 {
456 foreach (MailAddress item3 in message.CC)
457 {
458 mailAddressCollection.Add(item3);
459 }
460 }
461 if (mailAddressCollection.Count == 0)
462 {
464 }
465 _transport.IdentityRequired = false;
466 try
467 {
468 InCall = true;
469 _timedOut = false;
471 bool flag = false;
472 string pickupDirectoryLocation = PickupDirectoryLocation;
473 MailWriter mailWriter;
474 switch (DeliveryMethod)
475 {
476 case SmtpDeliveryMethod.PickupDirectoryFromIis:
477 throw new NotSupportedException(System.SR.SmtpGetIisPickupDirectoryNotSupported);
478 case SmtpDeliveryMethod.SpecifiedPickupDirectory:
479 if (EnableSsl)
480 {
481 throw new SmtpException(System.SR.SmtpPickupDirectoryDoesnotSupportSsl);
482 }
483 flag = IsUnicodeSupported();
484 ValidateUnicodeRequirement(message, mailAddressCollection, flag);
485 mailWriter = GetFileMailWriter(pickupDirectoryLocation);
486 break;
487 default:
489 flag = IsUnicodeSupported();
490 ValidateUnicodeRequirement(message, mailAddressCollection, flag);
491 mailWriter = _transport.SendMail(message.Sender ?? message.From, mailAddressCollection, message.BuildDeliveryStatusNotificationString(), flag, out exception);
492 break;
493 }
494 _message = message;
495 message.Send(mailWriter, DeliveryMethod != SmtpDeliveryMethod.Network, flag);
496 mailWriter.Close();
497 if (DeliveryMethod == SmtpDeliveryMethod.Network && exception != null)
498 {
499 throw exception;
500 }
501 }
502 catch (Exception ex)
503 {
504 if (System.Net.NetEventSource.Log.IsEnabled())
505 {
506 System.Net.NetEventSource.Error(this, ex, "Send");
507 }
508 if (ex is SmtpFailedRecipientException && !((SmtpFailedRecipientException)ex).fatal)
509 {
510 throw;
511 }
512 Abort();
513 if (_timedOut)
514 {
515 throw new SmtpException(System.SR.net_timeout);
516 }
517 if (ex is SecurityException || ex is AuthenticationException || ex is SmtpException)
518 {
519 throw;
520 }
521 throw new SmtpException(System.SR.SmtpSendMailFailure, ex);
522 }
523 finally
524 {
525 InCall = false;
526 if (_timer != null)
527 {
528 _timer.Dispose();
529 }
530 }
531 }
void Send(BaseWriter writer, bool sendEnvelope, bool allowUnicode)
SmtpDeliveryMethod DeliveryMethod
void ValidateUnicodeRequirement(MailMessage message, MailAddressCollection recipients, bool allowUnicode)
MailWriter GetFileMailWriter(string pickupDirectory)
void TimeOutCallback(object state)
MailWriter SendMail(MailAddress sender, MailAddressCollection recipients, string deliveryNotify, bool allowUnicode, out SmtpFailedRecipientException exception)
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 string net_inasync
Definition SR.cs:64
static string SmtpGetIisPickupDirectoryNotSupported
Definition SR.cs:172
static string SmtpFromRequired
Definition SR.cs:82
static string net_timeout
Definition SR.cs:66
static string SmtpSendMailFailure
Definition SR.cs:114
static string SmtpRecipientRequired
Definition SR.cs:112
static string SmtpPickupDirectoryDoesnotSupportSsl
Definition SR.cs:108
Definition SR.cs:7
bool Dispose(WaitHandle notifyObject)
Definition Timer.cs:176

References System.Net.Mail.SmtpClient._disposed, System.Net.Mail.SmtpClient._message, System.Net.Mail.SmtpClient._timedOut, System.Net.Mail.SmtpClient._timer, System.Net.Mail.SmtpClient._transport, System.Net.Mail.SmtpClient.Abort(), System.Net.Mail.MailAddressCollection.Add(), System.Net.NetEventSource.Associate(), System.Net.Mail.MailMessage.Bcc, System.Net.Mail.MailMessage.BuildDeliveryStatusNotificationString(), System.Net.Mail.MailMessage.CC, System.Net.Mail.SmtpClient.CheckHostAndPort(), System.Net.Mail.MailWriter.Close(), System.Collections.ObjectModel.Collection< T >.Count, System.Net.Mail.SmtpClient.DeliveryMethod, System.Threading.Timer.Dispose(), System.Net.Mail.SmtpClient.EnableSsl, System.Net.NetEventSource.Error(), System.exception, System.Net.Mail.MailMessage.From, System.FullName, System.Net.Mail.SmtpClient.GetConnection(), System.Net.Mail.SmtpClient.GetFileMailWriter(), System.Net.Mail.SmtpClient.InCall, System.Net.NetEventSource.Info(), System.Net.Mail.SmtpClient.IsUnicodeSupported(), System.item, System.Net.NetEventSource.Log, System.SR.net_inasync, System.SR.net_timeout, System.Net.Mail.SmtpClient.PickupDirectoryLocation, System.Net.Mail.MailMessage.Send(), System.Net.Mail.MailMessage.Sender, System.Net.Mail.SmtpTransport.SendMail(), System.SR.SmtpFromRequired, System.SR.SmtpGetIisPickupDirectoryNotSupported, System.SR.SmtpPickupDirectoryDoesnotSupportSsl, System.SR.SmtpRecipientRequired, System.SR.SmtpSendMailFailure, System.Net.Mail.SmtpClient.TimeOutCallback(), System.Net.Mail.MailMessage.To, and System.Net.Mail.SmtpClient.ValidateUnicodeRequirement().