SmtpIsSmtpContext Property
Indicates whether the component is currently operating in a single thread mode, and the current connection (if any) is an SMTP connection.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
public bool IsSmtpContext { get; }

Property Value

Type: Boolean
true if the current state of the component allows execution of any methods which are valid in a single SMTP connection mode only.

The Smtp component can operate in multi-thread mode, and is capable of establishing non-SMTP connections (while performing DNS MX lookup or POP-before-SMTP authentication). However, many Smtp class methods make sense only when a single SMTP connection is used at the moment. In this case, IsSmtpContext property can be used to make sure a call of such a method is possible.

If multi-threading, DNS MX lookup and POP-before-SMTP authentication are not used, this property will always return true. By default, multi-threading is not used (MaxThreadCount is 1), and automatic POP-before-SMTP authentication is off (AuthPopBeforeSmtp is false).

DNS MX lookup can be performed in direct send mode, when the message is being sent using mail send method like Send or RelayFromEmlFile(String, String, EmailAddressCollection) without prior Connect method call (and no SMTP servers were available in SmtpServers collections, or they had lower priority than the servers in DnsServers collection). If the connection was established by calling Connect method, DNS MX lookup will never be used.

The following are examples of methods which can only be used only if IsSmtpContext is true:

If the component was used in multiple-connections mode (for instance, the message was sent using MX lookup), the developer can revert it back to default mode using ResetState method.

See Also