Exemplo n.º 1
0
        private void Feedback()
        {
            try
            {
                if (check())
                {
                    Microsoft.Office.Interop.Outlook.Application opp  = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.MailItem    mail = (Microsoft.Office.Interop.Outlook.MailItem)opp.CreateItem(0);

                    mail.To = "*****@*****.**";


                    mail.Subject = this.cboSub.Text + ": " + txtSub.Text;
                    mail.Body    = this.txtBody.Text + System.Environment.NewLine + System.Environment.NewLine + "Sent using " + lblVer.Text;

                    mail.Send();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "One Click Functions", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (check())
                {
                    Microsoft.Office.Interop.Outlook.Application opp = new Microsoft.Office.Interop.Outlook.Application();
                    if (opp.DefaultProfileName != null)
                    {
                        Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)opp.CreateItem(0);

                        mail.To = "*****@*****.**";

                        mail.Subject = this.cboSub.Text + " for Kinect Slider: " + txtSub.Text;
                        mail.Body    = this.txtBody.Text + System.Environment.NewLine + System.Environment.NewLine + "Kinect Slider" + System.Environment.NewLine + "Sent using " + lblVer.Text;
                        mail.Send();
                        this.Close();

                        MessageBox.Show("Thank you for your feedback!", "Kinect Slider", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Couldnt find a Outlook profile. Please send a mail to [email protected]", "Kinect Slider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PowerPoint Kinect Slider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 3
0
        private void CreateMailItem(String Subject)
        {
            Microsoft.Office.Interop.Outlook.Application app      = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            mailItem.Subject = Subject + " " + currentDate.ToString("dd MMMM yyyy") + " - " + currentDate.ToString("hh:mm:ss tt");
            mailItem.To      = strTOMAIL;
            mailItem.Body    = "Hi\n\nPlease find my today's " + Subject + " " + currentDate.ToString("dd MMMM yyyy") + " - " + currentDate.ToString("hh:mm:ss tt") + "." + "\n\nSystem Details:\nUser Name: " + user_name + "\nHOSTNAME: " + hostname + "\nIP Address:" + IP_Address + "\nMAC Address: " + MAC_Address + "\nDOMAIN: " + domain_name + "\n\nThis is autogenerated email sent by Time Management System.\n\nThanks & Regards\n" + user_name;
            //mailItem.Attachments.Add(attachment_path); //attachment_path is a string holding path of the attachment
            mailItem.Importance = Outlook.OlImportance.olImportanceHigh;
            mailItem.Display(false);
            mailItem.Send();
        }
Exemplo n.º 4
0
        private String sendEmail(String subject, String body, String[] receivers)
        {
            try
            {
                //if Outlook is not open start it and wait
                Process[] pName = Process.GetProcessesByName("OUTLOOK");
                if (pName.Length == 0)
                {
                    // Open Outlook anew.
                    System.Diagnostics.Process.Start("OUTLOOK.EXE");
                    System.Threading.Thread.Sleep(2000);
                }

                //****
                Microsoft.Office.Interop.Outlook.Application app      = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.MailItem    mailItem = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

                //The email receiver
                //recipients
                Microsoft.Office.Interop.Outlook.Recipients recipients = mailItem.Recipients as Microsoft.Office.Interop.Outlook.Recipients;

                foreach (var email in receivers)
                {
                    recipients.Add(email);
                }

                mailItem.Subject = subject;
                mailItem.Body    = body;

                mailItem.Send();

                return("sent");
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                if (ex.ErrorCode == -2147417846)
                {
                    return("This Programm Use Outlock Service To Send Your Email, You Need To Execute Outlock First Than Send Your Email.");
                }
                else
                {
                    //return "Error, Email was Not sent";
                    return("sent");
                }
            }
        }
Exemplo n.º 5
0
        //отправляем каждому необходимые работы
        void SendEmails()
        {
            string prform_path;

            for (int i = 0; i < peers.Count; i++)
            {
                for (int j = 0; j < peers[i].new_guids.Count; j++)
                {
                    prform_path = session.Folder_path + @"\Review " + peers[i].guids_ID[j] + ".xlsm";
                    File.Copy(@"..\..\..\PATemplate_Example.xlsm", prform_path);
                    Excel.Application xlApp = new Excel.Application();
                    Excel.Workbook    Book  = xlApp.Workbooks.Open(prform_path);
                    Excel.Worksheet   Sheet = Book.Sheets[1];
                    Sheet.Cells[1, 2] = peers[i].prform_IDs[j];
                    Book.Close(true);
                    xlApp.Quit();
                    Book  = null;
                    Sheet = null;
                    Microsoft.Office.Interop.Outlook._Application _app = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.MailItem     mail = (Microsoft.Office.Interop.Outlook.MailItem)_app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                    mail.To      = peers[i].email;
                    mail.Subject = peers[i].prform_IDs[j] + " review for " + session.TaskTitle + peers[i].new_guids[j];
                    mail.Body    = "Hello!"
                                   + "\n" + "\t" + "Please see attached files." + "\n" + "Reply to this message with attached complete PR form (" + peers[i].prform_IDs[j] + ".xlsm) only."
                                   + "\n" + "Deadline for reviews is " + session.Review_End + "."
                                   + "\n\t" + "Truly yours, Peer Review Robot.";
                    mail.Attachments.Add(prform_path);
                    mail.Attachments.Add(Directory.GetFiles(session.Folder_path, $"{peers[i].new_guids[j]}*")[0]);
                    mail.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;
                    Outlook.Account account = GetOutlookAccount(_app, session.OutlookAccount);
                    mail.SendUsingAccount = account;
                    mail.Send();
                    _app.Quit();
                    _app = null;
                    mail = null;
                    File.Delete(prform_path);
                }
            }
        }
Exemplo n.º 6
0
        public static void ReadOutlook()
        {
            Outlook._Application olApp = new Outlook.ApplicationClass();
            Outlook._NameSpace   olNS  = olApp.GetNamespace("MAPI");
            olNS.Logon("@OutlookEmail", "@OutlookPassword", false, false);
            Outlook.MAPIFolder oFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

            TodayDate = DateTime.Now.ToString("MM/dd/yyyy");
            Outlook.Items oItems = oFolder.Items.Restrict("[ReceivedTime] >= '" + TodayDate + "'");
            //Outlook.Items oItems = oFolder.Items.Restrict("[UnRead] = true");

            for (int i = 1; i <= oItems.Count; i++)
            {
                Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oItems[i];
                MailSubject = oMsg.Subject.ToString();
                MailBody    = System.Web.HttpUtility.JavaScriptStringEncode(oMsg.Body);

                if (MailSubject.StartsWith("RE:") || MailSubject.StartsWith("FW:") || MailSubject.StartsWith("Re:") || MailSubject.StartsWith("Fw:") || MailSubject.StartsWith("Fwd:"))
                {
                    // Do not fetch mail with contains word above (reply and forward type)
                }
                else
                {
                    EmailCount++;
                    NewEmailList.Add(MailSubject);
                    Console.WriteLine(MailSubject + MailBody);
                    CreatJiraIssue(MailSubject, MailBody);
                }
            }
            ListName = string.Join("\n", NewEmailList.ToArray());
            Console.WriteLine(EmailCount);
            Microsoft.Office.Interop.Outlook.MailItem oMsgSend = (Outlook.MailItem)olApp.CreateItem(Outlook.OlItemType.olMailItem);
            oMsgSend.To      = "######Recieved_Email######";
            oMsgSend.To      = "######Sender_Email######";
            oMsgSend.Subject = "Summary Auto Email Fetching " + TodayDate;
            oMsgSend.Body    = "All New Email count: " + EmailCount + "\n\nFetching complete: " + EmailCount + "\n\nList Email names: \n\n" + ListName;
            oMsgSend.Save();
            oMsgSend.Send();
        }
Exemplo n.º 7
0
        private void Frnd()
        {
            try
            {
                if (check())
                {
                    Microsoft.Office.Interop.Outlook.Application opp  = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.MailItem    mail = (Microsoft.Office.Interop.Outlook.MailItem)opp.CreateItem(0);

                    mail.To = txtTO.Text;

                    mail.Subject = txtSub.Text;
                    mail.Body    = txtBody.Text;

                    mail.Send();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "One Click Functions", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }