public static void CheckMailToExecute() { try { Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI"); Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); Microsoft.Office.Interop.Outlook.Items oItems = myInbox.Items.Restrict("[UnRead] = True"); foreach (var item in oItems) { if (item is Microsoft.Office.Interop.Outlook.MailItem) { Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)item; if (mail.UnRead && mail.Subject.StartsWith("MC")) { mail.UnRead = false; ExecuteMail(mail); } } } } catch (Exception ex) { Logger.Log(ex.Message); } }
public static void SendEmail(string Receiver, string Obj, string path, string OrderID, string body) { 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 = Obj; mailItem.To = Receiver; mailItem.CC = "*****@*****.**"; if (body == "") { mailItem.Body = "Dear Supplier,\nPlease find our Purchase Order attached. In case of any questions / concerns, please contact me."; } else { mailItem.Body = body; } if (path != "") { String sSource = path; String sDisplayName = "PO_" + OrderID; int iPosition = (int)mailItem.Body.Length + 1; int iAttachType = (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue; mailItem.Attachments.Add(sSource, iAttachType, iPosition, sDisplayName); } mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; mailItem.Display(false); mailItem.Send(); mailItem = null; // Simple error handler. }
private void btnSend_Click(object sender, EventArgs e) { 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); foreach (DataGridViewRow row in dgvAttachment.Rows) { string isChecked = row.Cells[0].FormattedValue.ToString(); string filePath = row.Cells[3].Value.ToString(); if (isChecked == "True") { mailitem.Attachments.Add(filePath); GlobalService.AttachmentList.RemoveAll(x => x.FilePath == filePath); } } mailitem.Display(false); this.LoadAttachment(GlobalService.AttachmentList); if (GlobalService.AttachmentList.Count == 0) { this.DialogResult = DialogResult.OK; } }
private void btnHTMLSource_Click(object sender, RibbonControlEventArgs e) { // Get inspector Microsoft.Office.Interop.Outlook.Inspector currentInspector = this.Context as Microsoft.Office.Interop.Outlook.Inspector; // If inspector hasn't been initialized if (currentInspector == null) { return; } // Get current mail item from inspector Microsoft.Office.Interop.Outlook.MailItem currentMailItem = currentInspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem; if (currentMailItem != null) { // Init HTML Editor dialog box frmHTMLSource dialog = new frmHTMLSource(); dialog.Context = currentInspector; // Set title as an email subject dialog.Text = currentMailItem.Subject; try { // Set up highlight formatting as HTML dialog.txtHTMLSource.SetHighlighting("HTML"); // Copy HTML body from current email item dialog.txtHTMLSource.Text = currentMailItem.HTMLBody; } finally { dialog.ShowDialog(); } } }
//---- Genera email public static void GenerateEmail(string emailTo, string ccTo) { string rutaFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\DAS"; var directory = new DirectoryInfo(rutaFolder); string file = null; string ruta = null; try { 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); // Encuentra el archivo más nuevo en la carpeta file = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First().ToString(); ruta = rutaFolder + "\\" + file; // Direcciones oMsg.To = emailTo; oMsg.CC = ccTo; // Sujeto nombre del archivo y adjunta archivo oMsg.Subject = file; oMsg.Attachments.Add(ruta, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing); // Cuerpo del mensaje oMsg.HTMLBody = "Reporte generado con Asistente DAS. Puedes contribuir a este proyecto de código abierto en: https://github.com/RodrigoDiazC/Asistente-Das."; oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML; oMsg.Display(false); } catch (Exception e) { MessageBox.Show("Ocurrió un error al intentar generar el correo. Asegurate de tener Microsoft Outlook instalado.\n\nError: " + e.Message); } }
private void main() { string messageTo = ""; string messageBody = ""; string messageSubject = ""; Console.WriteLine("Who do you want to send the email to?"); messageTo = Console.ReadLine(); Console.WriteLine = ("What is the subject of the email?"); messageSubject = Console.ReadLine(); Console.WriteLine("What do you want the message to say?"); messageBody = Console.ReadLine(); try { Microsoft.Office.Interop.Outlook.Application objOutlook = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mailItem = objOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as Microsoft.Office.Interop.Outlook.MailItem; mailItem.Subject = messageSubject; mailItem.To = messageTo; mailItem.Body = messageBody; mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow; mailItem.Display(false); ((Microsoft.Office.Interop.Outlook._MailItem)mailItem).Send(); Console.WriteLine("Email Sent!"); } catch { MessageBox.Show("The email could not be sent!"); } }
private void radButton1_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Outlook.MailItem selection = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem; if (selection == null) { return; } var mailItem = selection; var bodyString = mailItem.HTMLBody; const string nbs = @" "; mailItem.HTMLBody = String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Artist Name</b>:{0}{1}</span>", nbs, textBox1.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Rep Owner/Label</b>:{0}{1}</span>", nbs, radioGroup1.Button.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Contracted With</b>:{0}{1}</span>", nbs, textBox2.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Contract Date</b>:{0}{1}</span>", nbs, radDateTimePicker1.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Document#</b>:{0}{1}</span>", nbs, textBox3.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Hummingbird#</b>:{0}{1}</span>", nbs, textBox4.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Section/Project#</b>:{0}{1}</span>", nbs, textBox5.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Subject/Comments</b>:{0}{1}</span>", nbs, textBox6.Text); mailItem.HTMLBody += String.Format("<span style='font-size:11.0pt;font-family:Calibri Light; color:#1F4E79;'><b>Document Type</b>:{0}{1}</span>", nbs, radioGroup2.Button.Text); mailItem.HTMLBody += String.Format(""); mailItem.HTMLBody += bodyString; }
/** * * This method will permanently delete an email from Outlook, similar to * the use of the shift+delete manually on an email in Outlook. * Surprise, surprise...Microsoft does not have a method to easily * perform a PERMANENT DELETE of an email...you literally have to move * the phish eMail to the Deleted Items folder first, and then delete it * from there. This is the only way, at least since the writing of this * comment, that we can permanently delete an email out of Outlook in * Visual C# * */ private void permanentlyDeleteEmail( Microsoft.Office.Interop.Outlook.MailItem currMail) { Microsoft.Office.Interop.Outlook.Explorer currExplorer = Globals.ThisAddIn.Application.ActiveExplorer(); Microsoft.Office.Interop.Outlook.Store store = currExplorer.CurrentFolder.Store; Microsoft.Office.Interop.Outlook.MAPIFolder deletedItemsFolder = store.GetRootFolder().Folders[DELETED_ITEMS_FOLDER_NAME]; // The move here will retain a reference to the MailItem entity that // is moved to the Deleted items folder...this is good because we // don't need to search for this email in Deleted Items...thank the // Maker! Microsoft.Office.Interop.Outlook.MailItem movedMail = currMail.Move(deletedItemsFolder); // Stupid Microsoft action here...need to change a value to trigger a // Save...otherwise, upcoming Delete will NOT OCCUR!!!! movedMail.Subject = movedMail.Subject + " "; // Need to save it... movedMail.Save(); // Now, permanently delete it! movedMail.Delete(); }
/// <summary> /// Metodo para enviar un correo por outlook /// </summary> /// <returns></returns> public bool enviarOutlook() { bool resultado = false; try { 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 = asunto; mailItem.To = destinatario; mailItem.Body = contenido; foreach (string rutaArchivo in rutaParam) { mailItem.Attachments.Add(rutaArchivo); } //Quita el warning de ambiguedad con el metodo send ((Microsoft.Office.Interop.Outlook._MailItem)mailItem).Send(); resultado = true; } catch (Exception) { } return(resultado); }
/// <summary> /// CreateMail /// </summary> /// <param name="chemin_pdf"></param> /// <param name="adresse_mail"></param> /// <param name="textBox_sujet_mail"></param> /// <param name="textBox_message_mail"></param> internal static void CreateMailOutlookAvecPJAndSend(string chemin_pdf, string adresse_mail, string textBox_sujet_mail, string textBox_message_mail) { StringBuilder msgBuilder = new StringBuilder(); Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.Subject = textBox_sujet_mail; mail.To = adresse_mail; mail.Body = textBox_message_mail; mail.Attachments.Add(chemin_pdf); try { // Envoie mail.Send(); } catch (Exception) { try { // Brouillon // mail.Save(); } catch (Exception) { throw; } } }
public void MultiSendEmail(object data) { string emailstr = data as string; string[] emaildata = emailstr.Split('☆'); try { 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 = emaildata[0] + ";" + emaildata[5]; mail.Attachments.Add(emaildata[1], Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing); mail.Subject = emaildata[2] + "(" + DateTime.Now.Date.ToString("M.dd") + ")"; mail.Body = emaildata[3]; //mail.Display(true); mail.Send(); mail = null; app = null; log = log + DateTime.Now.ToLongTimeString() + " " + emaildata[4] + "的邮件发送成功\r\n"; } catch (System.Exception ex) { notifyIcon1.ShowBalloonTip(2000, "提示", emaildata[4] + "的邮件发送失败", ToolTipIcon.None); log = log + DateTime.Now.ToLongTimeString() + " " + emaildata[4] + "的邮件发送失败\r\n"; restartemail[time1] = data as string; time1++; } }
public void CreateMailItem(string[] tabAdresse) { try { Microsoft.Office.Interop.Outlook._Application OutlookApp = new Microsoft.Office.Interop.Outlook.Application(); string toSend = ""; string addresseToAdd; //création du mail Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem) OutlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); //création de la liste d'adresse foreach (string addresse in tabAdresse) { if (addresse != "") { addresseToAdd = RemoveDiacritics(addresse); toSend += addresseToAdd + ";"; } } //remplissage des champs du mail toSend = toSend.TrimEnd(new char[] { ';' }); mailItem.Subject = "Judo"; mailItem.To = toSend; mailItem.Body = "Votre message"; mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow; mailItem.Display(true); } catch (Exception e) { throw new Exception("Erreur Metier.cs/CreateMailItem():\r\n" + e.Message, e); } }
protected String Construct_Final(string html_body, string iava_name, string iava_number, List <string> audits, Boolean save) { Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); // Regex exp = new Regex(@"Title:.*\r\n"); // Regex exp2 = new Regex(@"IAVM Notice Number:.*"); /* _MI_ temp_message = null; * temp_message = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); * temp_message.HTMLBody = html_body; * string plaintext_body = temp_message.Body; * MatchCollection Matches = exp.Matches(plaintext_body); * MatchCollection Matches2 = exp2.Matches(plaintext_body);*/ _MI_ finalmessage = null; finalmessage = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); // string iava_name = Matches[0].Value.Substring(Matches[0].Value.IndexOf(":") + 1).Trim(); // string iava_number = Matches2[0].Value.Substring(Matches2[0].Value.IndexOf(":") + 1).Trim().Substring(0, 11); string subj = "Acknowledgement: Release of " + iava_number + " - " + iava_name; finalmessage.Body = make_final_body(iava_number, iava_name, this.get_latest_build(), audits) + html_body; finalmessage.Subject = subj; finalmessage.To = "*****@*****.**"; // MessageBox.Show(this.get_build_num()); if (save) { this.Save_to_Draftbox(finalmessage); } return(finalmessage.Body.ToString()); }
/// <summary> /// Creation des mail outlook /// </summary> /// <param name="chemin_pdf"></param> /// <param name="adresse_mail"></param> /// <param name="textBox_sujet_mail"></param> /// <param name="textBox_message_mail"></param> public static void CreateMailOutlookAvecPJ(string chemin_pdf, string adresse_mail, string textBox_sujet_mail, string textBox_message_mail) { StringBuilder msgBuilder = new StringBuilder(); Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.Subject = textBox_sujet_mail; mail.To = adresse_mail; mail.HTMLBody = textBox_message_mail; mail.Attachments.Add(chemin_pdf); mail.Save(); // mail.Display(true); // Outlook.NameSpace omNamespace = outlookApp.GetNamespace("MAPI"); // Outlook.Recipient omUser = omNamespace.CreateRecipient("test"); // omUser.Resolve(); // Outlook.MAPIFolder doissierBrouillon = omNamespace.GetSharedDefaultFolder(omUser, Outlook.OlDefaultFolders.olFolderDrafts) // Dim omMailItem As Outlook.MailItem = CType(omDrafts.Items.Add, Outlook.MailItem) // With omMailItem // .SentOnBehalfOfName = "*****@*****.**" // .To = "*****@*****.**" // .Subject = "Test" // .Body = "Test email" // .Save() // .Move(omDrafts) }
private void btnImportHTML_Click(object sender, RibbonControlEventArgs e) { // Get inspector Microsoft.Office.Interop.Outlook.Inspector currentInspector = this.Context as Microsoft.Office.Interop.Outlook.Inspector; // If inspector hasn't been initialized if (currentInspector == null) { return; } // Get current mail item from inspector Microsoft.Office.Interop.Outlook.MailItem currentMailItem = currentInspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem; if (currentMailItem != null) { // Open file dialog to import HTML file OpenFileDialog dlgOpenHTML = new OpenFileDialog(); dlgOpenHTML.Filter = "HTML files (*.htm, *.html)|*.htm;*.html|All files (*.*)|*.*"; dlgOpenHTML.FilterIndex = 1; if (dlgOpenHTML.ShowDialog() == DialogResult.OK) { // Read a file and put it on body of current email item StreamReader stmReader = new StreamReader(dlgOpenHTML.FileName); currentMailItem.HTMLBody = stmReader.ReadToEnd(); } } }
private void button1_Click(object sender, EventArgs e) { PrincipalContext context2 = new PrincipalContext(ContextType.Domain, "gbl.ad.hedani.net", "OU=BR,OU=CS,DC=gbl,DC=ad,DC=hedani,DC=net"); PrincipalContext context = new PrincipalContext(ContextType.Domain, "csfb.cs-group.com", "OU=GroupsLocal,OU=SAO,OU=FAO,DC=csfb,DC=cs-group,DC=com"); foreach (var linha in richTextBox3.Lines) { UserPrincipal user = UserPrincipal.FindByIdentity(context2, richTextBox3.Text); foreach (var line in richTextBox1.Lines) { if (line != "") { try { GroupPrincipal group = GroupPrincipal.FindByIdentity(context, line); group.Members.Add(user); group.Save(); richTextBox2.AppendText("Usuario: " + user + " adicionado ao grupo" + line + "\n"); } catch (Exception x) { MessageBox.Show(x.Message); } } 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.To = "*****@*****.**"; mailItem.Subject = "AD Log - " + Environment.UserName + " - " + hoje; mailItem.Body = richTextBox2.Text; mailItem.Send(); } } }
public EUEmailUploadFile(string filePath, Microsoft.Office.Interop.Outlook.MailItem mailItem, EUFieldInformations fieldInformations, bool isListItemAndAttachment, SaveFormatOverride saveFormatOverride) // JOEL JEFFERY 20110710 - added safeFormatOverride { FilePath = filePath; MetaData = new EUEmailMetaData(mailItem); // JOEL JEFFERY 20110711 -- mailItem == null? surely not? if (mailItem == null) { //Subject = mailItem.Subject; //EntryID = mailItem.EntryID; //Body = mailItem.Body; } else { // JOEL JEFFERY 20110711 -- moved here Subject = mailItem.Subject; EntryID = mailItem.EntryID; Body = mailItem.Body; SentOn = mailItem.SentOn; IsEmail = true; } //MailItem = mailItem; UniqueID = Guid.NewGuid(); FieldInformations = fieldInformations; IsListItemAndAttachment = isListItemAndAttachment; // JOEL JEFFERY 20110710 SaveFormatOverride = saveFormatOverride; }
public RichEditMailMessageExporter(RichEditControl control, Microsoft.Office.Interop.Outlook.MailItem mailItem) { Guard.ArgumentNotNull(control, "control"); Guard.ArgumentNotNull(mailItem, "mailItem"); this.control = control; this.mailItem = mailItem; }
private void Outlook_ItemSend(object Item, ref bool Cancel) { Microsoft.Office.Interop.Outlook.MailItem mail = Item as Microsoft.Office.Interop.Outlook.MailItem; if (mail != null) { MessageBox.Show(string.Format("ItemSend {0} with DpiThreadAwarenessContext {1}", mail.Subject, DPIHelper.GetThreadDpiAwarenessContext().ToString())); } }
public async static Task <string> PostFormDataAsync(string URL, Microsoft.Office.Interop.Outlook.MailItem mail) { Dictionary <string, object> postParameters = new Dictionary <string, object>(); postParameters.Add("source", "Outlook"); postParameters.Add("id", mail.ConversationID); postParameters.Add("to", mail.To); postParameters.Add("from", mail.SenderName + "<" + mail.SenderEmailAddress + ">"); postParameters.Add("subject", mail.Subject); string seen = String.Format("{0:ddd MMM dd yyyy HH:mm:ss}", mail.SentOn) + " " + TimeZone.CurrentTimeZone; //postParameters.Add("seen", "Fri Mar 23 2018 13:38:29 GMT+0530 (India Standard Time)"); DateTimeOffset local_offset = new DateTimeOffset(mail.SentOn); DateTimeOffset utc_offset = local_offset.ToUniversalTime(); seen = String.Format("{0:ddd MMM dd yyyy HH:mm:ss}", utc_offset) + " GMT+530 (India Standard Time)"; postParameters.Add("seen", seen); string OffSet = " " + local_offset.ToString("%K").Replace(":", "").Trim(); postParameters.Add("sentdate", String.Format("{0:ddd,dd MMM yyyy HH:mm:ss}", mail.SentOn) + OffSet); postParameters.Add("receiveddate", String.Format("{0:ddd,dd MMM yyyy HH:mm:ss}", mail.ReceivedTime) + OffSet); postParameters.Add("HtmlMessagebody", mail.HTMLBody); postParameters.Add("PlainTextMessagebody", mail.Body); foreach (Microsoft.Office.Interop.Outlook.Attachment item in mail.Attachments) { //Save attachments and provide path. string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Point5Nyble\Mailtangy\"; if (Directory.Exists(filePath)) { item.SaveAsFile(filePath + item.FileName); } else { Directory.CreateDirectory(filePath); item.SaveAsFile(filePath + item.FileName); } FileStream fs = new FileStream(filePath + item.FileName, FileMode.Open, FileAccess.Read); byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); fs.Close(); postParameters.Add("attachfiles", new FileParameter(data, item.FileName, getContentType(filePath + item.FileName))); File.Delete(filePath + item.FileName); } HttpWebResponse webResponse = await MultipartFormDataPost(URL, "OutlookAddin", postParameters); StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string fullResponse = responseReader.ReadToEnd(); webResponse.Close(); return(fullResponse); }
/// <summary> /// Takes an Outlook email object and searches the Body field /// </summary> /// <param name="email_obj">Microsoft.Office.Interop.Outlook.MailItem object</param> /// <param name="query">String to search for in Body</param> /// <returns>True/False on Found/Not found</returns> protected bool Search_Body(_MI_ email_obj, string query) { if (email_obj.Body.ToLower().Contains(query.ToLower())) { return(true); } return(false); }
public static void SendEmail(string _ToEmail, string _Subject, string _EmailBody) {//ok Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)(oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)); email.Recipients.Add(_ToEmail); email.Subject = _Subject; email.Body = _EmailBody; ((Microsoft.Office.Interop.Outlook.MailItem)email).Send(); }
/// <summary> /// Takes an Outlook email object and searches the Sender field /// </summary> /// <param name="email_obj">Microsoft.Office.Interop.Outlook.MailItem object</param> /// <param name="query">String to search for in Sender</param> /// <returns>True/False on Found/Not found</returns> protected bool Search_Sender(_MI_ email_obj, string query) { if (email_obj.SenderEmailAddress.ToLower().Contains(query.ToLower())) { return(true); } return(false); }
protected override void Execute(CodeActivityContext context) { Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); var mail = Mail.Get(context); var folder = Folder.Get(context); mail.Move(folder); }
public static void Send(MailTemplate mailTemplate) { var outlook = GetOutlookApplication(); Microsoft.Office.Interop.Outlook.MailItem mail = outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.Subject = mailTemplate.Subject; mail.Body = mailTemplate.Body; mailTemplate.Attachments.ForEach(a => mail.Attachments.Add(a, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing)); mail.Display(true); }
private void CreateMailItem(String name, String email) { 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 = "Latihan Pengiriman menggunakan WPF"; mailItem.To = email; mailItem.Body = "Penambahan data dengan nama: " + name + " dan email: " + email + " sudah berhasil disimpan ke database"; mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; mailItem.Display(false); }
public static string GetSenderEmailAddress(Microsoft.Office.Interop.Outlook.MailItem mapiObject) { Microsoft.Office.Interop.Outlook.PropertyAccessor oPA; string propName = "http://schemas.microsoft.com/mapi/proptag/0x0065001F"; oPA = mapiObject.PropertyAccessor; string email = oPA.GetProperty(propName).ToString(); return(email); }
private void CreateMailItem(String username, String password, String email) { 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 = "New user created"; mailItem.To = email; mailItem.Body = "Your account has been registered successfull.\nUsername : "******"\nPassword : "******"\nPlease change your password after your login is successfull."; mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; mailItem.Display(false); }
private void CreateEmailSentNewPassword(String email, String password) { Microsoft.Office.Interop.Outlook.Application application = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mailItem = application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mailItem.Subject = "Generate New Change Password sent to email exercise"; mailItem.To = email; mailItem.Body = "Succesfully change your password! Your new password : "******". Please login with username " + email + " and new password " + password; mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; mailItem.Display(false); }
public void SendEmail(string subject, string body, string email) { 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; mailItem.To = email; mailItem.Body = body; mailItem.Display(false); mailItem.Send(); }
public void Reload(Microsoft.Office.Interop.Outlook.MailItem mail) { curEmail = mail; try { dgvTickets.DataSource = null; dgvOpportunities.DataSource = null; backgroundWorker1.RunWorkerAsync(this); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public MessageWrapper(Microsoft.Office.Interop.Outlook.MailItem currentMessage) { this.currentMessage = currentMessage; }