예제 #1
0
        public void Dispose()
        {
            Log.Info("MailClient->Dispose()");

            try
            {
                if (Imap != null)
                {
                    lock (Imap.SyncRoot)
                    {
                        if (Imap.IsConnected)
                        {
                            Log.Debug("Imap->Disconnect()");
                            Imap.Disconnect(true, CancelToken);
                        }

                        Imap.Dispose();
                    }
                }

                if (Pop != null)
                {
                    lock (Pop.SyncRoot)
                    {
                        if (Pop.IsConnected)
                        {
                            Log.Debug("Pop->Disconnect()");
                            Pop.Disconnect(true, CancelToken);
                        }

                        Pop.Dispose();
                    }
                }

                if (Smtp != null)
                {
                    lock (Smtp.SyncRoot)
                    {
                        if (Smtp.IsConnected)
                        {
                            Log.Debug("Smtp->Disconnect()");
                            Smtp.Disconnect(true, CancelToken);
                        }

                        Smtp.Dispose();
                    }
                }

                Authenticated = null;
                SendMessage   = null;
                GetMessage    = null;

                StopTokenSource.Dispose();
            }
            catch (Exception ex)
            {
                Log.Error("MailClient->Dispose(Mb_Id={0} Mb_Addres: '{1}') Exception: {2}", Account.MailBoxId,
                          Account.EMail.Address, ex.Message);
            }
        }
        public void Dispose()
        {
            if (Imap != null)
            {
                if (Imap.IsConnected)
                {
                    Imap.Disconnect(true, CancelToken);
                }

                Imap.Dispose();
            }

            if (Pop != null)
            {
                if (Pop.IsConnected)
                {
                    Pop.Disconnect(true, CancelToken);
                }

                Pop.Dispose();
            }

            if (Smtp != null)
            {
                if (Smtp.IsConnected)
                {
                    Smtp.Disconnect(true, CancelToken);
                }

                Smtp.Dispose();
            }

            Authenticated = null;
            SendMessage   = null;
            GetMessage    = null;

            StopTokenSource.Dispose();
        }