예제 #1
0
        public void NewMessageWithAttachements(string to, string subject, string body, List <string> paths)
        {
            mailItem         = Application.CreateItem(OlItemType.olMailItem);
            mailItem.To      = to;
            mailItem.Subject = subject;
            mailItem.Body    = body;
            List <FileInfo> files = new List <FileInfo>();

            foreach (var filePath in paths)
            {
                if (File.Exists(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    files.Add(file);
                }
                else if (string.IsNullOrWhiteSpace(filePath) == false)
                {
                    throw new FileNotFoundException("Attachement not found: " + filePath);
                }
            }
            for (int i = 0; i < files.Count; i++)
            {
                mailItem.Attachments.Add(files[i].FullName, OlAttachmentType.olByValue, i + 1, files[i].Name);
            }
            mailItem.Display();
        }
        public void NewMessage(string to, string subject, string body, bool isHtmlBody, List <string> attachmentPath)
        {
            mailItem         = Application.CreateItem(OlItemType.olMailItem);
            mailItem.To      = to;
            mailItem.Subject = subject;

            if (isHtmlBody)
            {
                mailItem.BodyFormat = OlBodyFormat.olFormatHTML;
                mailItem.HTMLBody   = body;
            }
            else
            {
                mailItem.Body = body;
            }

            var attachmentIndex = 1;

            foreach (var path in attachmentPath)
            {
                if (File.Exists(path))
                {
                    FileInfo file = new FileInfo(path);
                    mailItem.Attachments.Add(file.FullName, OlAttachmentType.olByValue, attachmentIndex++, file.Name);
                }
                else
                {
                    throw new FileNotFoundException("Attachement not found: " + path);
                }
            }

            mailItem.Display();
        }
예제 #3
0
        private void CreateEmail(EmployeeData employee)
        {
            string bodyStr = "Dear " + employee.FirstName + "," + "\r\n" +
                             "\r\n" + "Your current vacation balance is " + employee.Vacation + " hours." +
                             "\r\n" + "Your current sick balance is " + employee.Sick + " hours.";
            string TO_Recipients = employee.FullName;
            string CC_Recipients = "";
            string subjectStr    = "Your Current Vacation Balance";

            OutlookApp otlApp     = new OutlookApp();
            MailItem   otlNewMail = otlApp.CreateItem(OlItemType.olMailItem);
            Type       WshShell   = Type.GetTypeFromProgID("WScript.Shell");

            otlNewMail.Display();
            otlNewMail.Subject = subjectStr;
            otlNewMail.To      = TO_Recipients;
            otlNewMail.CC      = CC_Recipients;
            var objDoc = otlApp.ActiveInspector().WordEditor;
            var objSel = objDoc.Windows(1).Selection;

            objSel.InsertBefore(bodyStr);

            WshShell   = null;
            otlNewMail = null;
            otlApp     = null;
        }
예제 #4
0
        static public void SendEmail()
        {
            Application app      = new Application();
            MailItem    mailItem = app.CreateItem(OlItemType.olMailItem);


            if (UrisGroup.tc == "AutoNet1")
            {
                UrisGroup.tc = "Atlanta";
            }

            mailItem.Subject = UrisGroup.JobNumber + " " + UrisGroup.tc + "A5 16pp Booklet Proofs";
            mailItem.To      = "Data Processsing Group<*****@*****.**>; 'DG Admin' < *****@*****.** >; 'DG Data Management' < *****@*****.** >; Gary Bell; Sean Costigan";

            mailItem.Attachments.Add(UrisGroup.dir + "\\" + UrisGroup.JobNumber + " " + UrisGroup.tc + " Booklet.pgp");
            mailItem.Importance = OlImportance.olImportanceHigh;
            mailItem.Display(false);



            var signature = mailItem.HTMLBody;
            var body      = "Please see attached " + UrisGroup.tc + " Booklets Proof";

            mailItem.HTMLBody = body + signature;
            //mailItem.Send();
        }
예제 #5
0
        public static void Send(string recipientAddress, string subject = null)
        {
            Application outlook       = new Application();
            var         emailTemplate = @"S:\Quality Assurance\#QA & COMPLIANCE Dept Functions#\Feedback Management\Feedback Register\Feedback Acknowledgement Template\Curtin Singapore Feedback Acknowledgement.oft";
            MailItem    mailItem      = (MailItem)outlook.CreateItemFromTemplate(emailTemplate);

            mailItem.To = recipientAddress;

            Accounts accounts = outlook.Session.Accounts;

            if (accounts != null)
            {
                foreach (Account account in accounts)
                {
                    if (account.SmtpAddress.ToLower() == "*****@*****.**")
                    {
                        mailItem.Sender = account.CurrentUser.AddressEntry;
                    }
                }

                if (!string.IsNullOrEmpty(subject))
                {
                    mailItem.Subject += $" - {subject}";
                }

                mailItem.Display(null);
            }
        }
예제 #6
0
        private void threaded_LogToDeveloper()
        {
            try
            {
                Thread.Sleep(1000 * 2);
                String log = this.logger.Cycle();

                MailItem oMailItem = (MailItem)this.outlook.CreateItem(OlItemType.olMailItem);
                oMailItem.To      = this.config.Address_LogGoesTo;
                oMailItem.Subject = "Here is my LOG";
                oMailItem.Body    = "as requested, my logfile.";
                oMailItem.Attachments.Add(log, OlAttachmentType.olByValue, 1, log);

                // oMailItem.Send();
                oMailItem.Display(false);

                oMailItem = null;
                Marshal.ReleaseComObject(oMailItem);
            }
            catch (Exception ex)
            {
                this.logger.WriteError("threaded_LogToDeveloper(): " + ex.Message);
                this.logger.WriteError(ex.StackTrace);
            }
        }
예제 #7
0
        private void ComposeEmail(string recipient, string cc, string bcc, string subject, string body)
        {
            try
            {
                log.Info("Email composition begun");
                Outlook outlook = null;
                if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
                {
                    outlook = (Outlook)Marshal.GetActiveObject("Outlook.Application");
                }
                else
                {
                    outlook = new Outlook();
                }

                MailItem email     = (MailItem)outlook.CreateItem(OlItemType.olMailItem);
                var      inspector = email.GetInspector;
                email.To       = recipient ?? string.Empty;
                email.CC       = cc ?? string.Empty;
                email.BCC      = bcc ?? string.Empty;
                email.Subject  = subject ?? string.Empty;
                email.HTMLBody = string.Format(@"<html><body style=""font-size:11pt"">{0}</body></html>{1}", body, email.HTMLBody);
                email.Display(false);
                log.Info("Email composition completed");
            }
            catch (System.Exception ex)
            {
                log.Error($"Message => {ex.Message}\nStacktrace => {ex.StackTrace}");
                throw ex;
            }
        }
예제 #8
0
        public void CreateOutlookEmailMethod(string emailTo1, string emailTo2, string emailTo3, string emailTo4,
                                             string emailCC1, string emailCC2, string emailCC3, string emailCC4,
                                             string emailSubject, string emailBody)
        {
            Application outlookApp = new Application();
            MailItem    email      = outlookApp.CreateItem(OlItemType.olMailItem);

            //SetMailFormat_2002_2003_2007_2010(email);//This doesn't do anything

            /*Formatting will follow through this method on the GHost side but Aetna
             * side changes the font back to 10pt somehow. I tried looking in Outlooks
             * settings but did not see anything.*/

            email.To = emailTo1 + ";" + emailTo2 + ";" + emailTo3 + ";" + emailTo4;
            email.CC = emailCC1 + ";" + emailCC2 + ";" + emailCC3 + ";" + emailCC4;


            email.BCC = "*****@*****.**";

            email.Subject = emailSubject;

            //string s = email.Body + email.HTMLBody;
            email.BodyFormat = OlBodyFormat.olFormatHTML;
            email.Display();
            //email.Body = emailBody;
            email.HTMLBody = emailBody + email.HTMLBody;//addes the default signature
            //email.Body = emailBody;
            //email.HTMLBody = s;
        }
예제 #9
0
파일: Main.cs 프로젝트: Yuuyake/Naga
        static void WriteCsirtMail() {
            string attachFile = Directory.GetCurrentDirectory() + "\\results.txt";
            var resultStr = header + "<br/>" + String.Join("",vtApi.results.Select(ss => ss.ToString() + "  <br/>"));
            //File.ReadAllText(attachFile).Replace("\r\n", "<p></p>").Replace("\t", "&#9;");
            OutlookApp outlookApp = new OutlookApp();
            MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);
            mailItem.Importance = OlImportance.olImportanceHigh;
            mailItem.Subject = "Hash Engellenmesi Hk.";
            // "pre" tag is standing for render as it is dont change anything, thats why we cannot tab on there
            mailItem.HTMLBody =
"<pre " + "style=\"font-family:'consolas'\" >" +
@"Merhaba,<br/>
Aşağıdaki -McAffee Detected?- değeri False ve NotInDB olan <strong>MD5 HASH'lerin engellenmesi</strong> ATAR sistemi üzerinden yapılmıştır.<br/>
Syg.<br/>
 " + resultStr + "</pre>";

            mailItem.To = speconfig.csirtMail;
            mailItem.CC = speconfig.ksdestekMail;
            if (!File.Exists(attachFile))
                Console.Write("\nAttached document " + attachFile + " does not exist", Color.Red);
            else {
                System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(attachFile);
                mailItem.Attachments.Add(attachFile, OlAttachmentType.olByValue, Type.Missing, Type.Missing);
            }
            mailItem.Display();
        }
예제 #10
0
        //Inicializador
        #region
        public NovaOrdem(MailItem Email, List <BL_Boleta> BoletasImportadas)
        {
            EmailRecebido = Email;
            Email.Display();

            InitializeComponent();
            CmbBoxOp.SelectedIndex = 0;

            Fundos = new BL_FIQ().Dados();
            //CODFUNDSRAPTOR = new BL_FIQ().Dados().Where(x => x.CODMASTER == 61984).Select(x => x.CODFUND).ToList();

            CmbCotista.DisplayMember  = "NOME";
            CmbCotista.ValueMember    = "CODCOT";
            CmbBoxFIQ.DisplayMember   = "NOME";
            CmbBoxFIQ.ValueMember     = "CODFUND";
            CmbBoxConta.DisplayMember = "DISPLAYCONTA";
            CmbBoxFIQ.DataSource      = Fundos;
            CmbBoxFIQ.SelectedIndex   = -1;

            LabelEmail.Text   = EmailRecebido.SenderName.ToString();
            LabelHora.Text    = EmailRecebido.ReceivedTime.ToShortTimeString();
            LabelAssunto.Text = EmailRecebido.Subject.ToString();

            this.TopMost = true;
        }
예제 #11
0
        //Gera Email de Confirmação
        private void BtnGerarEmail_Click(object sender, EventArgs e)
        {
            if (CmbBoxOrdem.SelectedIndex > -1)
            {
                List <BL_Boleta> BoletasAux = Boletas.Where(x => x.IDORDEM == CmbBoxOrdem.SelectedValue.ToString() && (x.STATUS == "Boletado" || x.STATUS == "Concluído")).ToList();

                //Header
                string HTML = "";

                if (CheckTabela.Checked)
                {
                    HTML = new HTML().ConfirmaTabela(BoletasAux);
                }
                else
                {
                    HTML = new HTML().ConfirmaIndividual(BoletasAux);
                }

                try
                {
                    foreach (MailItem email in new Microsoft.Office.Interop.Outlook.Application().ActiveExplorer().Selection)
                    {
                        MailItem Mail = email.ReplyAll();
                        Mail.Recipients.Add("*****@*****.**");
                        Mail.HTMLBody = HTML + Mail.HTMLBody;
                        Mail.Display();
                        break;
                    }
                }
                catch
                {
                    MessageBox.Show("Erro ao gerar o email.");
                }
            }
        }
예제 #12
0
        protected static void SendMail(string body, string subject, string attachmentFile)
        {
            if (attachmentFile != null)
            {
                IntPtr pidl = IntPtr.Zero;
                try {
                    pidl = NativeMethods.ILCreateFromPath(attachmentFile);
                    if (pidl != IntPtr.Zero)
                    {
                        NativeMethods.SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
                    }
                } finally {
                    if (pidl != IntPtr.Zero)
                    {
                        NativeMethods.ILFree(pidl);
                    }
                }
            }

            Application outlookApp = null;

            try {
                outlookApp = new Application();
            } catch (System.Exception ex) {
                GeneralLog.Write("Unable to start Outlook (exception data follows)");
                GeneralLog.Write(ex);
            }

            if (outlookApp == null)
            {
                var fallbackWindow = new SendMailFallbackWindow {
                    MessageBody = body
                };
                fallbackWindow.Show();
                fallbackWindow.Activate();

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = string.Format(
                    CultureInfo.InvariantCulture,
                    "mailto:[email protected]?subject={0}&body={1}",
                    Uri.EscapeDataString(subject),
                    Uri.EscapeDataString(body));
                Process.Start(psi);
            }
            else
            {
                try {
                    MailItem mail = outlookApp.CreateItem(OlItemType.olMailItem) as MailItem;
                    mail.Subject = subject;
                    mail.Body    = body;
                    mail.To      = "*****@*****.**";
                    mail.Display(Modal: false);
                } catch (System.Exception ex) {
                    GeneralLog.Write("Error composing Outlook e-mail (exception data follows)");
                    GeneralLog.Write(ex);
                }
            }
        }
예제 #13
0
        private void btnEmail_Click(object sender, RibbonControlEventArgs e)
        {
            MailItem mail = helper.CreateMailItem();

            mail.Display();
            mail.Subject = "这是一封普通邮件";
            mail.Body    = @"您好:";
        }
예제 #14
0
 public void NewMessage(string to, string subject, string body)
 {
     mailItem         = Application.CreateItem(OlItemType.olMailItem);
     mailItem.To      = to;
     mailItem.Subject = subject;
     mailItem.Body    = body;
     mailItem.Display();
     mailItem.Save();
 }
예제 #15
0
        private void button9_Click(object sender, EventArgs e)
        {
            OutlookApp outlookApp = new OutlookApp();
            MailItem   mailItem   = outlookApp.CreateItem(OlItemType.olMailItem);

            mailItem.Subject = ResponseName;
            mailItem.Body    = textBox1.Text;
            mailItem.Display(true);
        }
예제 #16
0
        /// <summary>
        /// Emails the situation to everyone in the list.
        /// </summary>
        private async void EmailSituation()
        {
            // Clean the messages.
            InformationMessage = string.Empty;

            // Generate the email content based on the template
            var emailTemplate        = new EmailTemplate(ProcessedDate, Lines);
            var emailTemplateContent = emailTemplate.TransformText();

            // Send the mail via Outlook
            // Check that the email button is disable just after clicking it.
            IsSendingEmail = true;
            try
            {
                await Task.Run(() =>
                {
                    OutlookApp outlookApp = new OutlookApp();
                    MailItem mailItem     = outlookApp.CreateItem(OlItemType.olMailItem);

                    foreach (var line in Lines)
                    {
                        mailItem.Recipients.Add(line.Person.Email);
                    }
                    mailItem.Recipients.ResolveAll();

                    mailItem.Subject = String.Format("Soumission des CRA : rapport du {0}", ProcessedDate.ToString("d"));

                    // Images are attached to the mail with a contentId; that way, they will be accessible in the mail
                    // via the attribute "cid".
                    // For instance: <img src="cid:croissantEmpty" />
                    // In Outlook, this attribute is the property that has the schema name
                    // http://schemas.microsoft.com/mapi/proptag/0x3712001E.
                    var appPath = AppDomain.CurrentDomain.BaseDirectory;

                    Attachment croissantEmptyAttachment = mailItem.Attachments.Add(Path.Combine(appPath, "Assets/croissant_empty.png"));
                    croissantEmptyAttachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "croissantEmpty");

                    Attachment croissantFilledAttachment = mailItem.Attachments.Add(Path.Combine(appPath, "Assets/croissant_filled.png"));
                    croissantFilledAttachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "croissantFilled");

                    Attachment croissantGreyedAttachment = mailItem.Attachments.Add(Path.Combine(appPath, "Assets/croissant_greyed.png"));
                    croissantGreyedAttachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "croissantGreyed");

                    mailItem.HTMLBody = emailTemplateContent;

                    mailItem.Display(false);
                });
            }
            catch (System.Exception)
            {
                InformationMessage = "Erreur lors de la préparation du message";
            }

            IsSendingEmail = false;

            Save();
        }
예제 #17
0
        public void Display()
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException("Object is disposed.");
            }

            _mailItem.Display();
        }
        public static void SendEMail(MailTemplate mailTemplate)
        {
            var      outlook = GetOutlookApplication();
            MailItem mail    = outlook.CreateItem(OlItemType.olMailItem);

            mail.Subject = mailTemplate.Subject;
            mail.Body    = mailTemplate.Body;
            mailTemplate.Attachments.ForEach(a => mail.Attachments.Add(a, OlAttachmentType.olByValue, Type.Missing, Type.Missing));
            mail.Display(true);
        }
예제 #19
0
        //https://stackoverflow.com/questions/56933847/how-to-show-form-region-button-on-my-ribbon-in-vsto-outlook-c-sharp
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            Microsoft.Office.Interop.Outlook.Application oApp = Globals.ThisAddIn.Application;
            NameSpace  oNs    = oApp.GetNamespace("MAPI");
            MAPIFolder oInbox = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
            Items      oItems = oInbox.Items;
            MailItem   oForm  = oItems.Add("IPM.Note");

            oForm.Display(false);
            oApp.ActiveInspector().SetCurrentFormPage("OutlookAddIn1.FormRegion1");
        }
예제 #20
0
        private void Send(GXMailMessage msg)
        {
            GXLogging.Debug(log, "Sending Message");
            if (session == null)
            {
                GXLogging.Error(log, "Could not start Outlook");
                throw new GXMailException("Could not start Outlook", 4);
            }

            if (editWindow < 0 || editWindow > 1)
            {
                GXLogging.Error(log, "Invalid EditWindow value");
                throw new GXMailException("Invalid EditWindow value", 28);
            }
            if (msg.To.Count == 0)
            {
                GXLogging.Error(log, "No main recipient specified");
                throw new GXMailException("No main recipient specified", 13);
            }

            try
            {
                MailItem newMessage = (MailItem)session.CreateItem(OlItemType.olMailItem);
                newMessage.Subject = msg.Subject;
                if (msg.Text.Length > 0)
                {
                    newMessage.Body = msg.Text;
                }
                if (msg.HTMLText.Length > 0)
                {
                    newMessage.HTMLBody = msg.HTMLText;
                }

                CopyRecipients(msg.To, newMessage.Recipients, RecipientType.TO);
                CopyRecipients(msg.CC, newMessage.Recipients, RecipientType.CC);
                CopyRecipients(msg.BCC, newMessage.Recipients, RecipientType.BCC);

                CopyAttachments(msg.Attachments, newMessage.Attachments);

                if ((editWindow == 1) || (!newMessage.Recipients.ResolveAll()))
                {
                    newMessage.Display(false);
                }
                else
                {
                    newMessage.Send();
                }
            }
            catch (System.Exception exc)
            {
                GXLogging.Error(log, "Could not send message", exc);
                throw new GXMailException("Could not send message (" + exc.Message + ")", 10);
            }
        }
예제 #21
0
파일: Helpers.cs 프로젝트: Yuuyake/Baykus
        /// <summary>
        ///
        /// </summary>
        /// <param name="rows"></param>
        static public void WriteSomeMail(List <Result> results)
        {
            var resultTable  = "NA";
            var cellProperty = @"<td width=130 nowrap valign=bottom style='width:97.75pt;border:none;height:15.0pt'>
                                 <p class=MsoNormal><span style='font-family:Calibri;mso-fareast-language:TR'>";
            var cellEnd      = @"<o:p></o:p></span></p></td>";

            try {
                //string headerSpan = @"<p class=MsoNormal><span style='font-size:12.0pt;font-family:Consolas;color:blue;mso-fareast-language:TR'>";
                string        tableHeader = "TABLE HEADER"; //Resources.tableHeader.Replace("01.08.19 - 11:07", DateTime.Now.ToString("dd/MM/yy - HH:mm"));
                List <string> excelRows   = new List <string>();
                foreach (Result result in results)
                {
                    var rowData = "";
                    result.ToArray().ToList().ForEach(rr => rowData += cellProperty + rr + cellEnd);
                    excelRows.Add("<tr style='mso-yfti-irow:2;height:15.0pt'> " + rowData + "</tr>"); // a table raw created
                }
                resultTable = tableHeader + String.Join("", excelRows) + "</table>";                  // end of the creating table
            }
            catch (System.Exception ee) {
                Console.Write("\n Creating table for mailing is failed . . . ", Color.Red);
                Console.Write("\n Exception: " + ee.Message, Color.Orange);
                resultTable = "No Table Created";
            }
            Outlook.Application OutApp   = new Outlook.Application();
            MailItem            mailItem = (MailItem)OutApp.CreateItem(OlItemType.olMailItem);

            mailItem.Importance = OlImportance.olImportanceHigh;
            mailItem.Subject    = "Scanning IP Addresses";
            // "pre" tag is standing for render as it is dont change anything, thats why we cannot tab on there
            mailItem.HTMLBody = "<pre " + "style=\"font-family:'Arial TUR'\" >" + @"Merhaba,<br/>
Ekteki Scanning IP raporlarına istinaden aşağıdaki <strong style='color:red;'>kırmızı olmayan IP'lerin</strong> erişimi blissadmin ile kesilmiştir.<br/>
Syg.<br/><br/>" + resultTable + "</pre>";

            mailItem.To = MainClass.speconfig.csirtMail + "," + MainClass.speconfig.altyapiMail;
            //mailItem.CC = MainClass.speconfig.atarMail;
            var attachFiles = Directory.GetFiles(Directory.GetCurrentDirectory()).
                              Where(ff => ff.Contains("Scanning IP Addresses") || ff.Contains("Acunn666")).ToList();

            if (attachFiles.Where(ff => !File.Exists(ff)).Count() > 0)
            {
                Console.Write("\nSome of the Attached documents( " + String.Join(",", attachFiles.Where(ff => !File.Exists(ff))) + " ) are missing", Color.Red);
            }
            else
            {
                System.Net.Mail.Attachment attachment;
                foreach (string att in attachFiles)
                {
                    attachment = new System.Net.Mail.Attachment(att);
                    mailItem.Attachments.Add(att, OlAttachmentType.olByValue, Type.Missing, Type.Missing);
                }
            }
            mailItem.Display();
        }
예제 #22
0
        protected void OpenMessage(string itemId)
        {
            Application app  = null;
            _NameSpace  ns   = null;
            MailItem    item = null;

            app = new Application();
            ns  = app.GetNamespace("MAPI");
            ns.Logon(null, null, false, false);
            item = ns.GetItemFromID(itemId);
            item.Display();
        }
예제 #23
0
파일: Main.cs 프로젝트: Yuuyake/Naga
 static void WriteAtarMail() {
     string attachFile = Directory.GetCurrentDirectory() + "\\results.txt";
     string mailBody = String.Join("", vtApi.results.Where(ss =>
         (ss.resultMc == "False" || ss.resultMc == "NotInDB") &&
         Regex.IsMatch(ss.md5, "^[0-9a-fA-F]{32}$", RegexOptions.Compiled)).Select(news => news.md5 + "<br/>"));
     OutlookApp outlookApp = new OutlookApp();
     MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);
     mailItem.To = speconfig.atarMail;
     mailItem.CC = speconfig.csirtMail;
     mailItem.Subject = speconfig.atarTitle + Naga.Helpers.userName + "_" + DateTime.Now.ToString("ddMMMMyyyy");
     mailItem.HTMLBody = "<p style=\"font-family:'consolas'\" >" + mailBody + "</p>";
     mailItem.Importance = OlImportance.olImportanceHigh;
     mailItem.Display();
 }
예제 #24
0
 public void CreateEmailAndAddAttachments(string tpsFilePath)
 {
     try
     {
         Application application = new Application();
         MailItem    item        = application.CreateItem(OlItemType.olMailItem);
         item.Attachments.Add(tpsFilePath);
         item.Display();
     }
     catch (System.Exception)
     {
         Utils.ShowMessageBox(Messages.OutlookError, Messages.TitleError);
     }
 }
예제 #25
0
 private void StyleButton_Click(object sender, EventArgs e)
 {
     CreateBodyMail();
     if (questionList.Items.Count == 0)
     {
         warningLabelEmpty.Text = "You can't create template with no questions";
     }
     else
     {
         //check if directory exist
         if (!Directory.Exists(Configuration.pathFileTemplate))
         {
             Directory.CreateDirectory(Configuration.pathFileTemplate);
         }
         if (czyEdytujemy == false)
         {
             if (textBox2.Text.Equals(""))
             {
                 warningLabelName.Text = "Please enter a name";
             }
             else
             {
                 if (File.Exists(Configuration.pathFileTemplate + "\\" + textBox2.Text + ".oft"))
                 {
                     warningLabelName.Text = "This file exists. We cannot save";
                 }
                 else
                 {
                     Application outlookApp = new Application();
                     MailItem    mailItem   = outlookApp.CreateItem(OlItemType.olMailItem);
                     mailItem.HTMLBody = CreateBodyMail();
                     mailItem.SaveAs(Configuration.pathFileTemplate + "\\" + textBox2.Text + ".oft");
                     mailItem.Display();
                     Close();
                 }
             }
         }
         else
         {
             MessageBox.Show("RZECZYWISCIE ZAPISUJEMY EDYTOWANY PLIK");
             Outlook.Application outlookApp = new Outlook.Application();
             MailItem            mailItem   = outlookApp.CreateItem(OlItemType.olMailItem);
             mailItem.HTMLBody = CreateBodyMail();
             string nazwaPliku = label1.Text.Substring(17);
             mailItem.SaveAs(Configuration.pathFileTemplate + "\\" + nazwaPliku);
             mailItem.Display();
             Close();
         }
     }
 }
예제 #26
0
        public void ComposeMessage(string email)
        {
            Application oApp = new Application();
            MailItem    oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
            Recipient   oRecip;

            oRecip = (Recipient)oMsg.Recipients.Add(email);
            oRecip.Resolve();
            oMsg.Display(true);

            //oRecip = null;
            //oMsg = null;
            //oApp = null;
        }
예제 #27
0
 private void _taskPaneControl_MailClicked(IMessageWrapper messageWrapper)
 {
     try
     {
         MailItem mailItem2 = (MailItem)Application.Session.GetItemFromID(messageWrapper.EntryId, messageWrapper.StoreId);
         if (mailItem2 != null)
         {
             mailItem2.Display();
         }
     }
     catch (COMException)
     {
         // Swallow exception
     }
 }
예제 #28
0
파일: Helpers.cs 프로젝트: Yuuyake/Baykus
        static public void WriteAtarMail(List <Result> results)
        {
            // finally, write rows list to Excel's rows
            string mailBody = String.Join("", results.Select(rr => rr.ip + "<br/>"));

            Outlook.Application outlookApp = new Outlook.Application();
            MailItem            mailItem   = outlookApp.CreateItem(OlItemType.olMailItem);

            mailItem.To         = MainClass.speconfig.atarMail;
            mailItem.CC         = MainClass.speconfig.csirtMail;
            mailItem.Subject    = MainClass.speconfig.atarTitle + MainClass.userName + "_" + DateTime.Now.ToString("ddMMMMyyyy");
            mailItem.HTMLBody   = "<p style=\"font-family:'consolas'\" >" + mailBody + "</p>";
            mailItem.Importance = OlImportance.olImportanceHigh;
            mailItem.Display();
        }
예제 #29
0
        public void Send()
        {
            var      app      = new Application();
            MailItem mailItem = app.CreateItem(OlItemType.olMailItem);

            mailItem.Subject = EmailSenderPreferences.EmailSubject;
            mailItem.To      = EmailSenderPreferences.EmailAddress;
            mailItem.Body    = EmailSenderPreferences.EmailMessageBody;
            var attachedFilePath = CreateExcelDocPreferences.CreatedDocumentDirectory +
                                   CreateExcelDocPreferences.CreatedDocumentName;

            mailItem.Attachments.Add(attachedFilePath);
            mailItem.Importance = OlImportance.olImportanceHigh;
            mailItem.Send();
            mailItem.Display(false);
        }
예제 #30
0
        }   //Prompts the user to enter the new alias to request

        private void CreateMailItem(string uun, string email)
        {
            Microsoft.Office.Interop.Outlook.Application app = new
                                                               Microsoft.Office.Interop.Outlook.Application();
            MailItem item = app.CreateItem(OlItemType.olMailItem);

            item.BodyFormat = OlBodyFormat.olFormatHTML;
            item.To         = "*****@*****.**";
            item.Subject    = "Email Alias";
            item.Body       = String.Format(
                "Hi,\n\n" +
                "Please could you set 0365 email alias {0} for UUN: {1}\n\n" +
                "Thanks,\n" +
                "ACE IT", email, uun);
            item.Display();
        }   //Creates a new Outlook email and populates all information