public override List <ApplicationItemProperty> GetApplicationFields(string filePath) { List <ApplicationItemProperty> returnApplicationItemProperties = new List <ApplicationItemProperty>(); List <ApplicationItemProperty> applicationItemProperties = ConfigurationManager.GetInstance().GetApplicationItemProperties(ApplicationTypes.Outlook); Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mailItem = null; if (filePath == null) { mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); } else { mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlook.CreateItemFromTemplate(filePath); } Microsoft.Office.Interop.Outlook.ItemProperties properties = mailItem.ItemProperties; for (int i = 0; i < properties.Count; i++) { Microsoft.Office.Interop.Outlook.ItemProperty property = properties[i]; ApplicationItemProperty applicationItemProperty = applicationItemProperties.FirstOrDefault(item => item.Name == property.Name); if (applicationItemProperty != null) { ApplicationItemProperty returnApplicationItemProperty = new ApplicationItemProperty( applicationItemProperty.Name, applicationItemProperty.DisplayName, applicationItemProperty.Type); returnApplicationItemProperty.Value = Convert.ChangeType(property.Value, applicationItemProperty.Type); returnApplicationItemProperties.Add(returnApplicationItemProperty); } } #region Writing the xml for field definitions /* * System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter("c:\\fields.xml", Encoding.UTF8); * // start writing! * writer.WriteStartDocument(); * writer.WriteStartElement("Outlook"); * writer.WriteStartElement("MailItem"); * writer.WriteStartElement("ItemProperties"); * System.Xml.XmlDocument document = new System.Xml.XmlDocument(); * System.Xml.XmlNode mainNode = document.CreateNode(System.Xml.XmlNodeType.Element, "MailItem", "Outlook"); * for (int i = 0; i < properties.Count; i++) * { * writer.WriteStartElement("Property"); * writer.WriteAttributeString("Name", properties[i].Name); * writer.WriteAttributeString("DisplayName", properties[i].Name); * writer.WriteAttributeString("Type", properties[i].Type.ToString()); * writer.WriteEndElement(); * } * writer.WriteEndElement(); * writer.WriteEndElement(); * writer.WriteEndElement(); * writer.WriteEndDocument(); * writer.Close(); */ #endregion return(returnApplicationItemProperties); }
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(); }
public void SendEmail(string strTo, string strCC, string strSubject, string strHtmlBody) { Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.MailItem item = app.CreateItem(Outlook.OlItemType.olMailItem); item.HTMLBody = strHtmlBody; item.To = strTo; item.CC = strCC; item.Subject = strSubject; item.Recipients.ResolveAll(); item.Send(); }
override public string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "") { if (!ActiveSection.isEnabled) { return(""); } #if EnableOutlook try { Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem); /*(Outlook.AppointmentItem) * this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);*/ newAppointment.Start = ActiveSection.Start.toTimeZoneTime().DateTime; // DateTimeOffset.Now.AddHours(2); newAppointment.End = ActiveSection.End.toTimeZoneTime().DateTime; // DateTimeOffset.Now.AddHours(3); newAppointment.Location = "TBD"; newAppointment.Body = "JustTesting"; newAppointment.AllDayEvent = false; string SubJectString = ActiveSection.getId + "**" + NameOfParentCalendarEvent; if (ActiveSection.getIsComplete) { //SubJectString = ActiveSection.ID + "*\u221A*" + NameOfParentCalendarEvent; } newAppointment.Subject = SubJectString;// ActiveSection.ID + "**" + NameOfParentCalendarEvent; /*newAppointment.Recipients.Add("Roger Harui"); * Outlook.Recipients sentTo = newAppointment.Recipients; * Outlook.Recipient sentInvite = null; * sentInvite = sentTo.Add("Holly Holt"); * sentInvite.Type = (int)Outlook.OlMeetingRecipientType * .olRequired; * sentInvite = sentTo.Add("David Junca "); * sentInvite.Type = (int)Outlook.OlMeetingRecipientType * .olOptional; * sentTo.ResolveAll();*/ newAppointment.Save(); //newAppointment.EntryID; //newAppointment.Display(true); return(newAppointment.EntryID); } catch (Exception ex) { //MessageBox.Show("The following error occurred: " + ex.Message); return(""); } #endif return(""); }
static void MailOperations() { Console.WriteLine("Do You want to Compose a Mail with the Same Excel Attachement? Press [Y] for Yes any other key for N"); string input = Console.ReadLine(); if (input.ToLower().Contains("y")) { try { // Create the Outlook application. Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); // Create a new mail item. Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); // Set HTMLBody. //add the body of the email var statusDate = StatusDate.ToString("dd MMMM"); oMsg.Subject = "WP Daily Update – Subha Deb - " + statusDate; StringBuilder htmlBody = new StringBuilder(); htmlBody.Append("Hi,<br/> <br/> PFA the Status for " + statusDate); htmlBody.Append("<br/> <br/> Thanks, <br> Subha Deb"); oMsg.HTMLBody = htmlBody.ToString(); //Add an attachment. int iPosition = (int)oMsg.Body.Length + 1; int iAttachType = (int)Outlook.OlAttachmentType.olByValue; //now attached the file Outlook.Attachment oAttach = oMsg.Attachments.Add(GeneratedExcelFileNamePath, iAttachType, iPosition); // Add a recipient. Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients; // Change the recipient in the next line if necessary. foreach (var email in ReceipentsEmailIdsList) { Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(email); oRecip.Resolve(); oRecip = null; } oMsg.Display(true); // Send. //oMsg.Send(); // Clean up. oRecips = null; oMsg = null; oApp = null; }//end of try block catch (Exception ex) { Console.WriteLine("Got Exception"); Console.WriteLine(ex.ToString()); }//end of catch } }
public void ComposeEmail(string strTo, string strCC, string strSubject, string strHtmlBody, string strFolderEntryID, string strFolderStoreID) { Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.Folder DestFolder = app.Session.GetFolderFromID(strFolderEntryID, strFolderStoreID) as Outlook.Folder; Outlook.MailItem item = app.CreateItem(Outlook.OlItemType.olMailItem); item.HTMLBody = strHtmlBody; item.To = strTo; item.CC = strCC; item.Subject = strSubject; item.Display(); item.Save(); item.Move(DestFolder); }
public void send_email_via_outlook(bool battach, string filepath) { try { Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application(); Outlook.MailItem mailItem = (Outlook.MailItem)outlookObj.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "windows undocumented api demo"; mailItem.To = "*****@*****.**"; mailItem.Body = "hogehoge"; if (battach == true) { mailItem.Attachments.Add(filepath); //logPath is a string holding path to the log.txt file } mailItem.Display(false); } catch (Exception ex) { } }
public Microsoft.Office.Interop.Outlook.AppointmentItem findNextOccuranceOfThisMeeting(String subject, Microsoft.Office.Interop.Outlook.MAPIFolder calendar, Outlook.AppointmentItem calItem, String inviteeList) { Microsoft.Office.Interop.Outlook.Items oItems = (Microsoft.Office.Interop.Outlook.Items)calendar.Items; DateTime startDate = calItem.Start; oItems.Sort("[Start]", false); oItems.IncludeRecurrences = true; String StringToCheck = ""; StringToCheck = "[Start] > " + "\'" + startDate.ToString().Substring(0, startDate.ToString().IndexOf(" ") + 1).Trim() + "\'" + " AND [Subject] = '" + calItem.Subject.Trim() + "'"; // StringToCheck = "[Start] > " + "\'" + startDate.AddDays(1).ToString().Substring(0, startDate.ToString().IndexOf(" ")) + "\'" // + " AND [Subject] = '" + calItem.Subject.Trim() + "'"; Microsoft.Office.Interop.Outlook.Items restricted; restricted = oItems.Restrict(StringToCheck); restricted.Sort("[Start]", false); restricted.IncludeRecurrences = true; Microsoft.Office.Interop.Outlook.AppointmentItem oAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)restricted.GetFirst(); if (oAppt != null) //Next occurance found { //Outlook.MailItem em= Outlook.MailItem em = app.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem; em.HTMLBody = oAppt.Body; label_next_meeting.Visible = false; nextmeetingSubject.Text = oAppt.Subject.Trim(); nextMeetingLocation.Text = oAppt.Location != null?oAppt.Location.Trim() : ""; //MemoryStream stream = new MemoryStream(oAppt.RTFBody); nextMeetingBody.Rtf = System.Text.Encoding.ASCII.GetString(oAppt.RTFBody); //ASCIIEncoding.Default.GetBytes( //byte[] b = // nextMeetingBody.Rtf=stream. // nextMeetingBody.Html = em.HTMLBody; String timeTemp = oAppt.Start.ToString().Substring(oAppt.Start.ToString().IndexOf(" ") + 1); nextmeetingStartTime.Text = timeTemp.Substring(0, timeTemp.LastIndexOf(":")) + " " + (timeTemp.EndsWith("AM") ? "AM" : "PM"); timeTemp = oAppt.End.ToString().Substring(oAppt.End.ToString().IndexOf(" ") + 1); nextmeetingEndTime.Text = timeTemp.Substring(0, timeTemp.LastIndexOf(":")) + " " + (timeTemp.EndsWith("AM") ? "AM" : "PM"); dateTimePicker_nextMeetingDate.Checked = true; dateTimePicker_nextMeetingDate.Text = oAppt.Start.ToString(); styleInviteeList(inviteeList); //Load the attachment list if there are already uploaded attachment details for the next meeting if (oAppt.Attachments != null && oAppt.Attachments.Count > 0) { foreach (Outlook.Attachment atchItem in oAppt.Attachments) { dataGridView_next_meeting_atch.Rows.Add(atchItem.FileName.Trim(), ""); } } //textBox_next_invitees.Text = inviteeList; //=Convert.ToDateTime(oAppt.Start.ToString().Substring(oAppt.Start.ToString().IndexOf(" ") + 1)); return(oAppt); } else { label_next_meeting.Visible = true; nextmeetingSubject.Text = subject; styleInviteeList(inviteeList); //textBox_next_invitees.Text = inviteeList; //textBox_next_invitees.textfr return(null); } }
/// <summary> /// 预约会议响应事件 /// </summary> /// <param name="Ctrl"></param> /// <param name="CancelDefault"></param> public static void btnSchedule_Click(CommandBarButton Ctrl, ref bool CancelDefault) { ThisAddIn.g_log.Info("operator:btnCreateTPConfClicked begin"); try { //创建会议 Microsoft.Office.Interop.Outlook.Application ap = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem appt = ap.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem; if (null != appt) { appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting; appt.BusyStatus = Outlook.OlBusyStatus.olBusy; CreateUserProperties(ref appt);//创建自定义属性 Outlook.UserProperty property = appt.UserProperties.Find(ThisAddIn.PROPERTY_ENTER_FROM_SELF, Type.Missing); if (property != null) { property.Value = true; } appt.Display(false); } } catch (System.Exception ex) { ThisAddIn.g_log.Error(string.Format("create appointmentItem error: {0}", ex.ToString())); return; } //进入预约会议之前,弹出选择智真会议室提示框 if (ThisAddIn.g_SystemSettings.bShowTipsForSelectRooms == true) { TipsForSelectRoomsForm tips = new TipsForSelectRoomsForm(); tips.StartPosition = FormStartPosition.CenterScreen; tips.ShowDialog(); } ThisAddIn.g_log.Info("operator:btnCreateTPConfClicked end"); }
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(); } }
//отправляем каждому необходимые работы 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); } } }
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"); } } }
public void Flag(Element element, bool hasStart, DateTime startDate, CustomTimeSpan startTime, bool isStartAllDay, bool hasDue, DateTime dueDate, CustomTimeSpan dueTime, bool isDueAllDay, bool addToToday, bool addToReminder, bool addToTask) { Outlook.Application outlook_app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem app_item; Outlook.TaskItem task_item; if (hasStart || hasDue) { app_item = outlook_app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem) as Microsoft.Office.Interop.Outlook.AppointmentItem; if (isStartAllDay) { app_item.Start = startDate; app_item.AllDayEvent = true; element.StartDate = startDate; element.DueDate = startDate.AddDays(1); } else { if (startTime.IsAM == false) { startTime.Hour += 12; } string startDateTime = startDate.Month.ToString() + "/" + startDate.Day.ToString() + "/" + startDate.Year.ToString() + " " + startTime.Hour.ToString() + ":" + startTime.Minutes.ToString() + ":00"; if (dueTime.IsAM == false) { dueTime.Hour += 12; } string dueDateTime = dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString() + " " + dueTime.Hour.ToString() + ":" + dueTime.Minutes.ToString() + ":00"; app_item.Start = System.DateTime.Parse(startDateTime); app_item.End = System.DateTime.Parse(dueDateTime); app_item.AllDayEvent = false; element.StartDate = startDate; element.DueDate = dueDate; } if (addToReminder) { app_item.Body = "Start date for " + element.NoteText + @" <file:\\" + element.Path + ">"; app_item.Subject = element.NoteText; app_item.ReminderMinutesBeforeStart = 0; app_item.Save(); app_item = null; } } if (addToTask) { task_item = outlook_app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem) as Microsoft.Office.Interop.Outlook.TaskItem; task_item.Subject = element.NoteText; task_item.Body = "Task for " + element.NoteText + " " + element.Path; if (hasStart) { task_item.StartDate = startDate; } if (hasDue) { task_item.DueDate = dueDate; } task_item.ReminderSet = false; task_item.Save(); task_item = null; } if (addToToday) { Element today = GetTodayElement(); if (today != null) { Element newElement = CreateNewElement(ElementType.Note, element.NoteText); InsertElement(newElement, today, 0); AddAssociation(newElement, element.Path, ElementAssociationType.FolderShortcut, null); Promote(newElement); Flag(newElement); /*if (hasStart) { if (isStartAllDay) { } else { newElement.NoteText += " Start: " + startDate.Month.ToString() + "/" + startDate.Day.ToString() + "/" + startDate.Year.ToString() + " " + startTime.Hour.ToString() + ":" + startTime.Minutes.ToString(); } } if (hasDue) { if (isDueAllDay) { } else { newElement.NoteText += " Due: " + dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString() + " " + dueTime.Hour.ToString() + ":" + dueTime.Minutes.ToString(); } }*/ } } Flag(element); }
//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); // } }
private string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent) { try { Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem); /*(Outlook.AppointmentItem) this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);*/ newAppointment.Start = ActiveSection.Start;// DateTime.Now.AddHours(2); newAppointment.End = ActiveSection.End;// DateTime.Now.AddHours(3); newAppointment.Location = "TBD"; newAppointment.Body ="JustTesting"; newAppointment.AllDayEvent = false; newAppointment.Subject = ActiveSection.ID + "**" + NameOfParentCalendarEvent; /*newAppointment.Recipients.Add("Roger Harui"); Outlook.Recipients sentTo = newAppointment.Recipients; Outlook.Recipient sentInvite = null; sentInvite = sentTo.Add("Holly Holt"); sentInvite.Type = (int)Outlook.OlMeetingRecipientType .olRequired; sentInvite = sentTo.Add("David Junca "); sentInvite.Type = (int)Outlook.OlMeetingRecipientType .olOptional; sentTo.ResolveAll();*/ newAppointment.Save(); //newAppointment.EntryID; //newAppointment.Display(true); return newAppointment.EntryID; } catch (Exception ex) { MessageBox.Show("The following error occurred: " + ex.Message); return ""; } }
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(); } }
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(); } }