예제 #1
0
        private void StartSMTP()
        {
            try {
                sendClient      = new SmtpClient(smtpHost);
                sendClient.Port = 587;

                sendClient.Credentials = new System.Net.NetworkCredential("teameyepad", "highEyeGuy");
                sendClient.EnableSsl   = true;
            }
            catch
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }
예제 #2
0
 public void DeleteMessage(EmailMessage email)
 {
     using (ImapClient client = new ImapClient(imapHost, 993, username, password, AuthMethod.Login, true))
     {
         try { client.MoveMessage(email.getUID(), "[Gmail]/Trash"); }
         catch (BadServerResponseException e)
         {
             //be really sad
         }catch (Exception e)
         {
             ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
             mb.Show();
         }
     }
 }
예제 #3
0
        public void DeleteMessage(EmailMessage email)
        {
            using (ImapClient client = new ImapClient(imapHost, 993, username, password, AuthMethod.Login, true))
            {

                try { client.MoveMessage(email.getUID(), "[Gmail]/Trash"); }
                catch (BadServerResponseException e)
                {
                    //be really sad
                }catch(Exception e)
                {
                    ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                    mb.Show();
                }

            }
        }
예제 #4
0
 public void sendMessage(MailMessage message)
 {
     try
     {
         sendClient.Send(message);
     }
     catch (FormatException e)
     {
         ALSMessageBox mb = new ALSMessageBox("Invalid email format");
         mb.Show();
     }
     catch (Exception e)
     {
         ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
         mb.Show();
     }
 }
예제 #5
0
 public void sendMessage(string sourceAddress, string destinationAddress, string subject, string body)
 {
     try
     {
         MailMessage message = new MailMessage(sourceAddress, destinationAddress, subject, body);
         sendClient.Send(message);
     }
     catch (FormatException e)
     {
         ALSMessageBox mb = new ALSMessageBox("Invalid email format");
         mb.Show();
     }
     catch (Exception e)
     {
         ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
         mb.Show();
     }
 }
예제 #6
0
 public void sendMessage(EmailMessage mail)
 {
     try
     {
         MailMessage message = new MailMessage(mail.destinationAddress, mail.destinationAddress, mail.subject, mail.body);
         sendClient.Send(message);
     }
     catch (FormatException e)
     {
         ALSMessageBox mb = new ALSMessageBox("Invalid email format");
         mb.Show();
     }
     catch (Exception e)
     {
         ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
         mb.Show();
     }
 }
예제 #7
0
        private void StartSMTP()
        {
            try {
                sendClient = new SmtpClient(smtpHost);
                sendClient.Port = 587;

                sendClient.Credentials = new System.Net.NetworkCredential("teameyepad", "highEyeGuy");
                sendClient.EnableSsl = true;
            }
            catch
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }
예제 #8
0
        public void sendMessage(MailMessage message)
        {
            try
            {
                sendClient.Send(message);

            }
            catch (FormatException e)
            {
                ALSMessageBox mb = new ALSMessageBox("Invalid email format");
                mb.Show();
            }
            catch (Exception e)
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }
예제 #9
0
        public void sendMessage(string sourceAddress, string destinationAddress, string subject, string body)
        {
            try
            {
                MailMessage message = new MailMessage(sourceAddress, destinationAddress, subject, body);
                sendClient.Send(message);

            }
            catch (FormatException e)
            {
                ALSMessageBox mb = new ALSMessageBox("Invalid email format");
                mb.Show();
            }
            catch (Exception e)
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }
예제 #10
0
 public void sendMessage(EmailMessage mail)
 {
     try
     {
         MailMessage message = new MailMessage(mail.destinationAddress, mail.destinationAddress, mail.subject, mail.body);
         sendClient.Send(message);
     }
     catch (FormatException e)
     {
         ALSMessageBox mb = new ALSMessageBox("Invalid email format");
         mb.Show();
     }
     catch (Exception e)
     {
         ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
         mb.Show();
     }
 }
예제 #11
0
        public void retrieveMail(String mailbox = "INBOX")
        {
            currentMailBox = mailbox;
            MailList.Clear();

            if (imapHost.Equals(null) || imapHost.Equals(null) || password.Equals(null))
            {
                ALSMessageBox mb = new ALSMessageBox("Not logged in");
                mb.Show();
                return;
            }

            try {
                // The default port for IMAP over SSL is 993.
                using (ImapClient client = new ImapClient(imapHost, 993, username, password, AuthMethod.Login, true))
                {
                    folders = client.ListMailboxes();
                    Console.WriteLine("We are connected!");
                    // Returns a collection of identifiers of all mails matching the specified search criteria.
                    IEnumerable<uint> uids = null;
                    uids = client.Search(SearchCondition.All(), mailbox);
                    // Download mail messages from the default mailbox.
                    uint[] uidArray = uids.ToArray();
                    Array.Reverse(uidArray);

                    uids = uids.Reverse();

                    if (uidArray.Length > DOWNLOAD_COUNT)
                        Array.Resize(ref uidArray, DOWNLOAD_COUNT);

                    IEnumerable<MailMessage> messages = client.GetMessages(uidArray, FetchOptions.NoAttachments, true, mailbox);
                    IEnumerator<MailMessage> messageList = messages.GetEnumerator();
                    IEnumerator<uint> uidList = uids.GetEnumerator();

                    while (messageList.MoveNext())
                    {
                        uidList.MoveNext();

                        string toAddress;

                        try
                        {
                            toAddress = messageList.Current.To[0].Address;
                        }
                        catch
                        {
                            toAddress = "None";
                        }

                        EmailMessage temp = new EmailMessage(messageList.Current.Subject, messageList.Current.Body,
                            toAddress, messageList.Current.From.Address, EmailClient.Date(messageList.Current),
                            uidList.Current);

                        int hash = temp.GetHashCode();

                        bool contains = false;

                        foreach (EmailMessage m in MailList)
                        {
                            if (m.GetHashCode().Equals(hash))
                                contains = true;
                        }

                        if (!contains)
                        {
                            bool added = false;
                            int index = 0;
                            if (MailList.Count == 0)
                            {
                                MailList.Add(temp);
                            }
                            else
                            {

                                while (!added && index < MailList.Count)
                                {
                                    switch (MailList[index].CompareTo(temp))
                                    {
                                        case -1:
                                            MailList.Insert(index, temp);
                                            added = true;
                                            break;
                                        case 0:
                                            MailList.Insert(index, temp);
                                            added = true;
                                            break;
                                        case 1:
                                            index++;
                                            break;
                                        case -99: //error code
                                            break;
                                    }
                                }
                                if (!added)
                                    MailList.Add(temp);
                            }

                        }

                    }

                }

                MailList.Reverse();
            }
            catch (InvalidCredentialsException)
            {

            }catch(System.Net.Sockets.SocketException e)
            {
                ALSMessageBox mb = new ALSMessageBox("Not connected to internet");
                mb.Show();
            }catch(Exception e)
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }
예제 #12
0
        public void retrieveMail(String mailbox = "INBOX")
        {
            currentMailBox = mailbox;
            MailList.Clear();

            if (imapHost.Equals(null) || imapHost.Equals(null) || password.Equals(null))
            {
                ALSMessageBox mb = new ALSMessageBox("Not logged in");
                mb.Show();
                return;
            }


            try {
                // The default port for IMAP over SSL is 993.
                using (ImapClient client = new ImapClient(imapHost, 993, username, password, AuthMethod.Login, true))
                {
                    folders = client.ListMailboxes();
                    Console.WriteLine("We are connected!");
                    // Returns a collection of identifiers of all mails matching the specified search criteria.
                    IEnumerable <uint> uids = null;
                    uids = client.Search(SearchCondition.All(), mailbox);
                    // Download mail messages from the default mailbox.
                    uint[] uidArray = uids.ToArray();
                    Array.Reverse(uidArray);

                    uids = uids.Reverse();

                    if (uidArray.Length > DOWNLOAD_COUNT)
                    {
                        Array.Resize(ref uidArray, DOWNLOAD_COUNT);
                    }

                    IEnumerable <MailMessage> messages    = client.GetMessages(uidArray, FetchOptions.NoAttachments, true, mailbox);
                    IEnumerator <MailMessage> messageList = messages.GetEnumerator();
                    IEnumerator <uint>        uidList     = uids.GetEnumerator();

                    while (messageList.MoveNext())
                    {
                        uidList.MoveNext();

                        string toAddress;

                        try
                        {
                            toAddress = messageList.Current.To[0].Address;
                        }
                        catch
                        {
                            toAddress = "None";
                        }

                        EmailMessage temp = new EmailMessage(messageList.Current.Subject, messageList.Current.Body,
                                                             toAddress, messageList.Current.From.Address, EmailClient.Date(messageList.Current),
                                                             uidList.Current);

                        int hash = temp.GetHashCode();

                        bool contains = false;

                        foreach (EmailMessage m in MailList)
                        {
                            if (m.GetHashCode().Equals(hash))
                            {
                                contains = true;
                            }
                        }

                        if (!contains)
                        {
                            bool added = false;
                            int  index = 0;
                            if (MailList.Count == 0)
                            {
                                MailList.Add(temp);
                            }
                            else
                            {
                                while (!added && index < MailList.Count)
                                {
                                    switch (MailList[index].CompareTo(temp))
                                    {
                                    case -1:
                                        MailList.Insert(index, temp);
                                        added = true;
                                        break;

                                    case 0:
                                        MailList.Insert(index, temp);
                                        added = true;
                                        break;

                                    case 1:
                                        index++;
                                        break;

                                    case -99:     //error code
                                        break;
                                    }
                                }
                                if (!added)
                                {
                                    MailList.Add(temp);
                                }
                            }
                        }
                    }
                }

                MailList.Reverse();
            }
            catch (InvalidCredentialsException)
            {
            }catch (System.Net.Sockets.SocketException e)
            {
                ALSMessageBox mb = new ALSMessageBox("Not connected to internet");
                mb.Show();
            }catch (Exception e)
            {
                ALSMessageBox mb = new ALSMessageBox("Unknown error occurred");
                mb.Show();
            }
        }