GSF.Net.Smtp.Mail.Dispose C# (CSharp) Method

Dispose() public method

Releases all the resources used by the Mail object.
public Dispose ( ) : void
return void
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

Same methods

Mail::Dispose ( bool disposing ) : void

Usage Example

Esempio n. 1
0
        // Send an email address notifying the admin of a changes in the flat-lined status of measurements.
        private void SendEmailNotification(IEnumerable<IMeasurement> measurements, bool flatlined)
        {
            Ticks now = DateTime.Now.Ticks;
            Mail message = new Mail("*****@*****.**", m_adminEmailAddress, m_smtpServer);
            StringBuilder body = new StringBuilder();

            body.AppendLine("Measurement Key, Value, Timestamp");

            foreach (IMeasurement measurement in measurements)
            {
                body.Append(measurement.Key);
                body.Append(", ");
                body.Append(measurement.AdjustedValue);
                body.Append(", ");
                body.Append(measurement.Timestamp);
                body.AppendLine();

                if (flatlined)
                    m_lastNotified[measurement.Key] = now;
                else
                    m_lastNotified.Remove(measurement.Key);
            }

            if (flatlined)
                message.Subject = "Flat-lined measurements";
            else
                message.Subject = "No longer flat-lined measurements";

            message.Body = body.ToString();
            message.Send();
            message.Dispose();
        }