Ejemplo n.º 1
0
        public void GetAttachmentsByRegex(string regex)
        {
            MailSearcher ms        = new MailSearcher();
            Items        mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            foreach (var item in ms.GetInboxItems(OlDefaultFolders.olFolderInbox))
            {
                try
                {
                    if (item is MailItem mailItem)
                    {
                        if (mailItem.Attachments.Count > 0)
                        {
                            foreach (Attachment attachment in mailItem.Attachments)
                            {
                                if (Regex.Match(attachment.FileName, regex).Success)
                                {
                                    if (download)
                                    {
                                        attachment.SaveAsFile(downloadFolder.TrimEnd('\\') + "\\" + attachment.FileName);
                                    }
                                    else
                                    {
                                        Common.DisplayMailItem(mailItem);
                                    }
                                }
                            }
                        }
                    }
                    else if (item is MeetingItem meetingItem)
                    {
                        if (meetingItem.Attachments.Count > 0)
                        {
                            foreach (Attachment attachment in meetingItem.Attachments)
                            {
                                if (Regex.Match(attachment.FileName, regex).Success)
                                {
                                    if (download)
                                    {
                                        attachment.SaveAsFile(downloadFolder.TrimEnd('\\') + "\\" + attachment.FileName);
                                    }
                                    else
                                    {
                                        Common.DisplayMeetingItem(meetingItem);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public void SearchBySenderName(string name)
        {
            MailSearcher ms = new MailSearcher();

            Items mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            Console.WriteLine("[+] Searching for e-mails from: {0}", name);
            foreach (var item in mailItems)
            {
                try
                {
                    if (item is MailItem mailItem)
                    {
                        if (mailItem.SenderName.ToLower().Contains(name.ToLower()))
                        {
                            Common.DisplayMailItem(mailItem);
                        }
                    }

                    if (item is MeetingItem meetingItem)
                    {
                        if (meetingItem.SenderEmailAddress.ToLower().Contains(name.ToLower()))
                        {
                            Common.DisplayMeetingItem(meetingItem);
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 3
0
        public void GetAll(bool display = false)
        {
            MailSearcher ms        = new MailSearcher();
            Items        mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            if (mailItems.Count > 200 && !force)
            {
                Console.WriteLine("[!] Warning: You are about to display the information of over 200 e-mail subjects. Are you sure you don't want to search by keyword or name? Use /force to bypass this warning.\r\n[!] Current Count: {0}", mailItems.Count);
                return;
            }
            Console.WriteLine("[+] Getting all e-mail items");
            foreach (var item in mailItems)
            {
                try
                {
                    if (item is MailItem mailItem)
                    {
                        Common.DisplayMailItem(mailItem);
                    }

                    if (item is MeetingItem meetingItem)
                    {
                        Common.DisplayMeetingItem(meetingItem);
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 4
0
        private void MonitorEmailRegex(string regex)
        {
            MailSearcher ms = new MailSearcher();

            Console.WriteLine("[+] Starting e-mail monitoring...");
            Items mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            mailItems.ItemAdd += new ItemsEvents_ItemAddEventHandler(NewEmailEvent);
            Console.WriteLine("[+] Started, press Ctrl+Z to exit");
        }
Ejemplo n.º 5
0
        public void GetAllAttachments()
        {
            Console.WriteLine("Getting All Attachments\r\nDownload = " + download);
            Console.WriteLine(downloadFolder);
            MailSearcher ms = new MailSearcher();

            //Items mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            foreach (var item in ms.GetInboxItems(OlDefaultFolders.olFolderInbox))
            {
                try
                {
                    if (item is MailItem mailItem)
                    {
                        if (mailItem.Attachments.Count > 0)
                        {
                            if (download)
                            {
                                foreach (Attachment attachment in mailItem.Attachments)
                                {
                                    attachment.SaveAsFile(downloadFolder.TrimEnd('\\') + "\\" + attachment.FileName);
                                }
                            }
                            else
                            {
                                Common.DisplayMailItem(mailItem);
                            }
                        }
                    }
                    else if (item is MeetingItem meetingItem)
                    {
                        if (meetingItem.Attachments.Count > 0)
                        {
                            if (download)
                            {
                                foreach (Attachment attachment in meetingItem.Attachments)
                                {
                                    attachment.SaveAsFile(downloadFolder.TrimEnd('\\') + "\\" + attachment.FileName);
                                }
                            }
                            else
                            {
                                Common.DisplayMeetingItem(meetingItem);
                            }
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 6
0
        public void ReadEmailBySubject(string subject)
        {
            MailSearcher ms        = new MailSearcher();
            Items        mailItems = ms.GetInboxItems(OlDefaultFolders.olFolderInbox);

            Console.WriteLine("[+] Searching for e-mails, with the subject: {0}", subject);
            try
            {
                foreach (var item in mailItems)
                {
                    if (item is MailItem mailItem)
                    {
                        string body = "";
                        if (!String.IsNullOrEmpty(mailItem.Body))
                        {
                            body = mailItem.Body;
                        }
                        if (mailItem.Subject.Contains(subject))
                        {
                            Console.WriteLine(body);
                        }
                    }

                    if (item is MeetingItem meetingItem)
                    {
                        string body = "";
                        if (!String.IsNullOrEmpty(meetingItem.Body))
                        {
                            body = meetingItem.Body;
                        }
                        if (meetingItem.Subject.Contains(subject))
                        {
                            Console.WriteLine(body);
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }