Example #1
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();
        }
Example #2
0
        //public string DailyMediaReportSMTP(DateTime todaysdate)
        //{
        //    try
        //    {

        //        string fileName = Server.MapPath("../") + "Report\\" + "DailyMediaReport -11-20-2018.pdf";
        //        //fileName = "\\dpw-cisweb-tst\\E$\\Inetpub\\WWWRoot\\Communications\\" + "Report\\" + fileName;
        //        OpenOutLookSMTP(fileName);//DailyMediaReport -11-20-2018
        //        return "true";

        //    }
        //    catch (Exception ex)
        //    {
        //        var resultPdfReport = new { Valid = false, Message = ex.InnerException };

        //        var exeception = ex.Message;
        //        // andy
        //        //return false;
        //        return exeception;
        //    }
        //    finally
        //    {
        //        //check stream length or if stream not close, close stream
        //        //Same here, use report.Close();
        //    }
        //}

        //Old method-HP
        public void OpenOutLook(string fileName)
        {
            Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            //Verify it haritha
            //Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem)
            //using oMsg{
            //oMsg.To = "Daily Media Report Contacts";
            oMsg.To         = "*****@*****.**";
            oMsg.Subject    = "Department of Public Works Daily Media Log for " + System.DateTime.Now.ToShortDateString() + ".";
            oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            oMsg.HTMLBody   =
                "The attached log sheet reflects media contact information as of 2:30 p.m. today. Information received" +
                " afterwards will be listed on next day\'s log with date noted.";
            //oMsg.HTMLBody =
            //     "The attached log sheet reflects media contact information as of " + System.DateTime.Now.ToShortTimeString() + " today. Information received" +
            //    " afterwards will be listed on next day\'s log with date noted.";
            oMsg.Attachments.Add(fileName, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
            oMsg.Display(oMsg);
            // }
        }