Esempio n. 1
0
        //private MailItem mailItem = null;
        //private Microsoft.Office.Interop.Outlook.TaskItem taskItem = null;
        //private int counter = 0;

        public static void sendmail(string address, string subject, string message)
        {
            MailItem mailItem = null;

            Microsoft.Office.Interop.Outlook.TaskItem taskItem = null;
            int counter = 0;

            try
            {
                Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();


                //  ae = new AddressEntry


                mailItem         = ((MailItem)myApp.CreateItem((OlItemType.olMailItem)));
                mailItem.Subject = subject;

                mailItem.To   = address;
                mailItem.Body = message;

                // Send the email to the customer
                ((_MailItem)mailItem).Send();
            }

            catch (System.Exception ex)
            {
                throw;
            }
        }
Esempio n. 2
0
        public static void sendmail(string address, string subject, string TextMessage, string HTMLMessage, string[] Attachments, MessageType Type)
        {
            MailItem mailItem = null;

            Microsoft.Office.Interop.Outlook.TaskItem taskItem = null;
            int counter = 0;

            try
            {
                Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();


                //  ae = new AddressEntry


                mailItem         = ((MailItem)myApp.CreateItem((OlItemType.olMailItem)));
                mailItem.Subject = subject;

                mailItem.To = address;



                if (Type == MessageType.html)
                {
                    mailItem.HTMLBody = HTMLMessage;
                }
                else if (Type == MessageType.text)
                {
                    mailItem.Body = TextMessage;
                }

                if (Attachments.Length > 0)
                {
                    foreach (string item in Attachments)
                    {
                        //  Attachment att = new Attachment(item);
                        mailItem.Attachments.Add(item);
                    }
                }


                // Send the email to the customer
                ((_MailItem)mailItem).Send();
            }

            catch (System.Exception ex)
            {
                throw;
            }
        }
Esempio n. 3
0
        public void CreateTaskClicked(IRibbonControl control)
        {
            var selection = _application.ActiveExplorer().Selection.Cast <MailItem>();
            var mailItem  = selection.ElementAt(0);

            var folder = mailItem.Parent as Folder;

            // Create guid for mail here
            string guid = GetNewOrExistingGuid(mailItem);

            TaskItem taskItem = (TaskItem)_application.CreateItem(OlItemType.olTaskItem);

            taskItem.Subject = mailItem.Subject;
            taskItem.Body    = Utils.RemoveHyperLinks(mailItem.Body) + "\n\n" + Utils.BuildMailItemLink(mailItem, folder, guid);
            taskItem.Display();
        }
Esempio n. 4
0
        public void Send_Sheets_woform(Office.IRibbonControl control)
        {
            string tempfile = Path.Combine(Path.GetTempPath(), Globals.ThisWorkbook.Name.ToString());
            Globals.ThisWorkbook.SaveCopyAs(tempfile);

            try
            {
                if (ServerDocument.IsCustomized(tempfile))
                {
                    ServerDocument.RemoveCustomization(tempfile);
                }
                Microsoft.Office.Interop.Outlook.Application outlookapp = new Microsoft.Office.Interop.Outlook.Application();
                MailItem eMail = (MailItem)outlookapp.CreateItem(OlItemType.olMailItem);
                eMail.Subject = "SidneyN from elance: Workbook Attached: " + Globals.ThisWorkbook.Name.ToString();
                eMail.Attachments.Add(tempfile);
                eMail.Display(true);
                File.Delete(tempfile);
            }
            catch (System.Exception e)
            {
                //Error Removing Customization and Sending email.
            }
        }
Esempio n. 5
0
        private async void button1_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Outlook.Application     outlookApplication = new Microsoft.Office.Interop.Outlook.Application();;
            Microsoft.Office.Interop.Outlook.AppointmentItem appointment        = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
            created_by = appointment.SendUsingAccount.UserName;
            ((Microsoft.Office.Interop.Outlook.ItemEvents_10_Event)appointment).Send += new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(MailItemSendedHandler);
            meetingroom_Id = Convert.ToInt32(meetingroom_name);
            from           = dateTimePicker1.Value.Date.ToString("MM/dd/yyyy ") + dateTimePicker3.Value.TimeOfDay;
            to             = dateTimePicker2.Value.Date.ToString("MM/dd/yyyy ") + dateTimePicker4.Value.TimeOfDay;

            string url = domain + "/MeetingRooms/NewReservation?from=" + from + "&to=" + to + "&created_by=" + created_by +
                         "&meetingroom_Id=" + meetingroom_Id;

            using (var client = new HttpClient())
            {
                var response = client.GetAsync(url).Result;
                if (response.IsSuccessStatusCode)
                {
                    // by calling .Result you are performing a synchronous call
                    var responseContent = response.Content;
                    // by calling .Result you are synchronously reading the result
                    code = await response.Content.ReadAsAsync <string>();
                }
            }
            StringBuilder html = new StringBuilder();

            html = buildhtml();
            TimeSpan ConvertZoneDays = new TimeSpan(2, 0, 0);

            appointment.Body  = html.ToString();
            appointment.Start = DateTime.Parse(dateTimePicker1.Value.Date.ToString("MM/dd/yyyy"));
            appointment.End   = DateTime.Parse(dateTimePicker2.Value.Date.ToString("MM/dd/yyyy"));
            TimeZoneInfo newTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Egypt Standard Time");

            appointment.StartUTC = TimeZoneInfo.ConvertTime(DateTime.Parse(from), newTimeZone);
            appointment.StartUTC = appointment.StartUTC.Subtract(ConvertZoneDays);
            appointment.EndUTC   = TimeZoneInfo.ConvertTime(DateTime.Parse(to), newTimeZone);
            appointment.EndUTC   = appointment.EndUTC.Subtract(ConvertZoneDays);
            appointment.Location = meetingroom_name;
        }