Beispiel #1
0
        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!");
            }
        }
Beispiel #2
0
        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.
        }
Beispiel #3
0
        //---- 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 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;
            }
        }
Beispiel #5
0
 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);
     }
 }
Beispiel #6
0
 public static void SendMail(string subject, string Body, string FilePath)
 {
     oMail.Subject    = subject;
     oMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
     oMail.Body       = Body;
     oMail.Attachments.Add(FilePath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
     oMail.Display(false);
 }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 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();
 }
 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);
 }
 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);
 }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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    to       = To.Get(context);
            var    cc       = CC.Get(context);
            var    bcc      = BCC.Get(context);
            var    subject  = Subject.Get(context);
            string body     = (Body != null ?Body.Get(context) : null);
            string htmlbody = (HTMLBody != null ? HTMLBody.Get(context) : null);

            if (!string.IsNullOrEmpty(htmlbody))
            {
                body = htmlbody;
            }
            var attachments = Attachments.Get(context);
            var uiaction    = UIAction.Get(context);

            email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
            email.To         = to;
            email.Subject    = subject;
            email.HTMLBody   = body;
            email.CC         = cc;
            email.BCC        = bcc;

            if (attachments != null && attachments.Count() > 0)
            {
                foreach (var attachment in attachments)
                {
                    if (!string.IsNullOrEmpty(attachment))
                    {
                        email.Attachments.Add(attachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing);
                    }
                }
            }
            if (uiaction == "Show")
            {
                email.Display(true);
            }
            //else if(uiaction == "SendVisable")
            //{
            //    email.Display(true);
            //    email.Send();
            //}
            else
            {
                email.Send();
            }
            if (EMail != null)
            {
                EMail.Set(context, new email(email));
            }
        }
 private void CreateMailItem(string workItemNum)
 {
     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 = "Impact Analysis - New Item wad added: " + workItemNum;
     mailItem.To      = Settings.Default.MailRecipients;
     mailItem.Body    = "WorkItem number : " + workItem + " was added!";
     mailItem.Attachments.Add(Settings.Default.ImpactAnalysisExcelPath);
     mailItem.Display(false);
     mailItem.Send();
 }
Beispiel #14
0
        async private void DoGenerateMail(object obj)
        {
            try
            {
                WorkInProgress = true;
                if (DeliveryBatch != null)
                {
                    var result = await RestHub.GenerateEmail(DeliveryBatch.Id);

                    if (result.HttpCode == System.Net.HttpStatusCode.OK)
                    {
                        try
                        {
                            Microsoft.Office.Interop.Outlook.Application oApp     = new Microsoft.Office.Interop.Outlook.Application();
                            Microsoft.Office.Interop.Outlook.MailItem    mailItem = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

                            mailItem.To         = "*****@*****.**";
                            mailItem.CC         = "[email protected];[email protected]";
                            mailItem.Subject    = "Reactions Mail";
                            mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                            mailItem.HTMLBody   = result.UserObject.ToString();
                            mailItem.Display(false);
                        }
                        catch (Exception ex)
                        {
                            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{DeliveryBatch.BatchNumber}.html");
                            File.WriteAllText(path, result.UserObject.ToString());
                            AppInfoBox.ShowInfoMessage($"Unfortunately Outlook is not accessible. The prepared report will open in web browser, you may copy and paste in email manually.");
                            Process.Start(path);
                        }
                    }
                    else
                    {
                        AppErrorBox.ShowErrorMessage("Error While Generating Email . .", Environment.NewLine + result.HttpResponse);
                    }
                    DeliveryInProgress = Visibility.Hidden;
                }
                else
                {
                    MessageBox.Show("From Batch, From Category, Delivery Batch Number Is Required . . .");
                }
                WorkInProgress = false;
            }
            catch (Exception ex)
            {
                AppErrorBox.ShowErrorMessage("Can't generate mail report . .", ex.ToString());
            }
            finally
            {
                WorkInProgress = false;
            }
        }
Beispiel #15
0
        private void btnEmail_Click(object sender, EventArgs e)
        {
            try
            {
                Image bit = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);

                Graphics gs = Graphics.FromImage(bit);

                gs.CopyFromScreen(new Point(0, 0), new Point(0, 0), bit.Size);

                //bit.Save(@"C:\temp\temp.jpg");


                Rectangle bounds = this.Bounds;
                using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                {
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                    }
                    bitmap.Save(@"C:\temp\temp.jpg");
                }


                Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.MailItem    mailItem   = outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                mailItem.Subject = "";
                mailItem.To      = "";
                string imageSrc = @"C:\Temp\temp.jpg"; // Change path as needed

                var attachments = mailItem.Attachments;
                var attachment  = attachments.Add(imageSrc);
                attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x370E001F", "image/jpeg");
                attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "myident"); // Image identifier found in the HTML code right after cid. Can be anything.
                mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B", true);

                // Set body format to HTML

                mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                mailItem.Attachments.Add(imageSrc);
                string msgHTMLBody = "";
                mailItem.HTMLBody = msgHTMLBody;
                mailItem.Display(true);
            }
            catch { }
        }
Beispiel #16
0
 public void SendMail()
 {
     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    = $"ახალი თანამშრომელი {inp_fullname.Text.Trim()}";
         mailItem.To         = "*****@*****.**";
         mailItem.HTMLBody   = body;
         mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
         mailItem.Display(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #17
0
        private new void MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            DataRowView selectedRow  = gridView.SelectedItem as DataRowView;
            string      name         = selectedRow["name"].ToString();
            string      invertedName = String.Join(" ", name.Split(' ').Reverse().ToArray());
            string      email        = selectedRow["mail"].ToString();
            string      phone        = selectedRow["phone"].ToString();
            string      job          = selectedRow["job"].ToString();
            string      centre       = selectedRow["centre"].ToString();

            Console.WriteLine("DoubleClick triggered on e-mail :" + email);

            MessageBoxResult result = MessageBox.Show(
                "NOM: " + invertedName + "\n" +
                "FONCTION: " + job + "\n" +
                "CENTRE: " + centre + "\n" +
                "TELEPHONE: " + phone + "\n" +
                "MAIL: " + email + "\n" +
                " \n Écrire un mail à " + invertedName + " ?\n", "Fiche de " + invertedName, MessageBoxButton.YesNo
                );

            switch (result)
            {
            case MessageBoxResult.Yes:
                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);

                oMsg.Recipients.Add(email);
                oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                oMsg.HTMLBody   = "";
                oMsg.Display(true);
                break;

            case MessageBoxResult.No:
                // Nothing
                break;

            default:
                // Nothing
                break;
            }
        }
Beispiel #18
0
        public Result SendMailTo(String customerMail)
        {
            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    = "This is the subject";
                mailItem.To         = customerMail;
                mailItem.Body       = "This is the message.";
                mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
                mailItem.Display(false);
                mailItem.Send();

                return(new Result(Status.Success));
            }
            catch (Exception e)
            {
                return(new Result(message: Message.NULL, status: Status.Error, exception: e));
            }
        }
Beispiel #19
0
        public static void Email_Screen()
        {
            try
            {
                System.Drawing.Image bit = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);

                Graphics gs = Graphics.FromImage(bit);

                gs.CopyFromScreen(new Point(0, 0), new Point(0, 0), bit.Size);

                bit.Save(@"C:\temp\temp2.jpg");
            }
            catch
            {
            }



            Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    mailItem   = outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mailItem.Subject = "";
            mailItem.To      = "";
            string imageSrc = @"C:\Temp\temp2.jpg"; // Change path as needed

            var attachments = mailItem.Attachments;
            var attachment  = attachments.Add(imageSrc);

            attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x370E001F", "image/jpeg");
            attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "myident"); // Image identifier found in the HTML code right after cid. Can be anything.
            mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B", true);

            // Set body format to HTML

            mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            mailItem.Attachments.Add(imageSrc);
            string msgHTMLBody = "";

            mailItem.HTMLBody = msgHTMLBody;
            mailItem.Display(true);
            //mailItem.Send();
        }
Beispiel #20
0
        public void CreateMailItem(string subject, string sendto, string message, string sendCC)
        {
            if (Environment.UserName.ToUpper() == "TP10")
            {
                sig = "Regards\n\nTyrone Pearce\nIT Process Developer\nfor TLT LLP\nD: +44 (0)333 006 0810\nF: +44 (0)333 006 0810\nwww.TLTsolicitors.com";
            }
            if (Environment.UserName.ToUpper() == "GS12")
            {
                sig = "Thanks\n\nGarrie Selway\nIT Process Developer\nExt: 61354";
            }
            if (Environment.UserName.ToUpper() == "GB06")
            {
                sig = "Thanks,\n\nGeorge.\n\nGeorge Braund\nIT Process Developer\nExt:61087";
            }
            if (Environment.UserName.ToUpper() == "AA09")
            {
                sig = "Thanks,\n\nAsh\n\nAshley Andrews\nIT Process Developer\nExt: 61086";
            }
            if (Environment.UserName.ToUpper() == "DM16")
            {
                sig = "Thanks,\n\nDrew Musgrove\nIT Process Developer\nExt: 61135";
            }
            message = message + "\n" + sig;

            Microsoft.Office.Interop.Outlook.Application mailApp  = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    mailItem = (Microsoft.Office.Interop.Outlook.MailItem)mailApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mailItem.Subject    = subject;
            mailItem.To         = sendto;
            mailItem.CC         = sendCC;
            mailItem.Body       = message;
            mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow;
            //mailItem.HTMLBody = message;
            if (autosend == false)
            {
                mailItem.Display(true);
            }
            else
            {
                mailItem.Send();
            }
        }
Beispiel #21
0
        // need to add reference Microsoft.Office.Interop.Outlook - its on the COM tab
        private void sendEmail(string recordName, string Drafter, string ProjectNumber, string ProjectName, string SubProject, string comments, string cadFileName)
        {
            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 = $"Drawing Updated: {ProjectNumber} - {ProjectName} - {SubProject}";
            mailItem.To      = "*****@*****.**";
            mailItem.Body    = $"Drafter {Drafter} has updated CAD File at this location: {cadFileName}.{Environment.NewLine}" +
                               $"{Environment.NewLine}" +
                               $"Note:{Environment.NewLine}" +
                               $"{comments}";
            //mailItem.Attachments.Add(logPath);//logPath is a string holding path to the log.txt file

            try
            {
                mailItem.Display(true); //THIS IS THE CHANGE;
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot create Outlook email object, perhaps Outlook object is open?");
            }
        }
Beispiel #22
0
        private void sendEmail(string recordName, string Drafter, string ProjectNumber, string ProjectName, string SubProject)
        {
            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 = $"{ProjectNumber} - {ProjectName} - {SubProject} : Drawing Change Requested";
            mailItem.To      = "*****@*****.**";
            mailItem.Body    = $"Hi {Drafter}, {Environment.NewLine}" +
                               $"{Environment.NewLine}" +
                               $"Please update the drawing with the following edits..." +
                               $"{Environment.NewLine}";
            //mailItem.Attachments.Add(logPath);//logPath is a string holding path to the log.txt file

            try
            {
                mailItem.Display(true); //THIS IS THE CHANGE;
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot create Outlook email object, perhaps Outlook object is open?");
            }
        }
Beispiel #23
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            string guid        = Guid.NewGuid().ToString();
            string appDataPath = Environment.GetEnvironmentVariable("temp");
            string filePath1   = appDataPath + @"\icFront" + guid + ".jpg";
            string filePath2   = appDataPath + @"\icBack" + guid + ".jpg";
            string inkFile1    = appDataPath + @"\inkFront" + guid + ".isf";
            string inkFile2    = appDataPath + @"\inkBack" + guid + ".isf";
            string zipPath     = appDataPath + @"\postcard" + guid + ".ipc";

            CreateImageFiles(filePath1, icFront);
            CreateImageFiles(filePath2, icBack);
            CreateZipFile(zipPath, filePath1, filePath2);

            Microsoft.Office.Interop.Outlook.Application app  = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    mail = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mail.HTMLBody = @"<p>Open this postcard in the app to bring it to life, and create your own!</p><img src='cid:" + "icFront" + guid + ".jpg" + "' width=480 height=270/><p>  </p><img src='cid:" + "icBack" + guid + ".jpg" + "' width=480 height=270/><p/><a href='https://www.microsoft.com/store/apps/9NBNHTJPCS5F'>Sent from InkPostcard App</a>";
            mail.Attachments.Add(filePath1);
            mail.Attachments.Add(filePath2);
            mail.Attachments.Add(zipPath);
            mail.Display();
        }
Beispiel #24
0
        public void OpenOutLook(string Body, string Subject, string client, string location, string matterID)
        {
            Kill_process();
            Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    mail   = null;
            mail         = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mail.Body    = Body;
            mail.Subject = Subject;
            mail.To      = client;
            if (CostAgreement)
            {
                mail.Attachments.Add((object)@"" + location + "\\" + matterID + "-CostsAgreement.pdf",
                                     Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Costs Agreement");
            }
            if (EngagementLetter)
            {
                mail.Attachments.Add((object)@"" + location + "\\" + matterID + "-EngagementLetter.pdf",
                                     Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Engagement Letter");
            }

            if (TaxInvoice)
            {
                mail.Attachments.Add((object)@"" + location + "\\" + matterID + "-TaxInvoice.pdf",
                                     Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Tax Invoice");
            }
            if (DisclosureStatement)
            {
                mail.Attachments.Add((object)@"" + location + "\\" + matterID + "-DisclosureStatement.pdf",
                                     Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Disclosure Statement");
            }
            if (PaymentReceipt)
            {
                mail.Attachments.Add((object)@"" + location + "\\" + matterID + "-PaymentReceipt.pdf",
                                     Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Payment Receipt");
            }
            //To show email window
            mail.Display();
        }
Beispiel #25
0
        private void CreateMailWithAttachmentNr6(string officialPositionWhoGetNewNotification, string numberLastNotification, string attachmentPath)
        {
            System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
            int collCount = processes.Length;

            if (collCount != 0)
            {
                Microsoft.Office.Interop.Outlook.Application oApp     = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
                Microsoft.Office.Interop.Outlook.MailItem    mailItem = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                mailItem.Subject = "PIW Olesno - zgłoszenia padniecia numer " + "1608/" + numberLastNotification + "/2019" + ".";
                if (mainWindow.comboBox_UtilizationCompany.Text == "Jasta")
                {
                    mailItem.To = "[email protected], [email protected]";
                    mailItem.CC = "radomsko.piw @wetgiw.gov.pl, [email protected], [email protected]";
                }
                else if (mainWindow.comboBox_UtilizationCompany.Text == "Farmutil")
                {
                    mailItem.To = "*****@*****.**";
                    mailItem.CC = "[email protected], [email protected], [email protected]";
                }
                else
                {
                    mailItem.To = " ";
                }
                mailItem.Body = "Zgłoszenie padnięcia nr " + "1608/" + numberLastNotification + "/2019" + ". \nPIW Olesno\n" + officialPositionWhoGetNewNotification + "\n" + mainWindow.comboBox_WhoGetGetNotification.Text;
                Microsoft.Office.Interop.Outlook.Attachments mailAttachments = mailItem.Attachments;
                Microsoft.Office.Interop.Outlook.Attachment  newAttachment   = mailAttachments.Add(
                    attachmentPath + numberLastNotification + "-" + mainWindow.txtFarmNumber.Text + "-zal6-" + savingDateTime + ".pdf",
                    Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1, "Załącznik nr 6");
                mailItem.Save();
                mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;
                mailItem.Display(false);
                mailItem = null;
                oApp     = null;
                MessageBox.Show("Utworzono wiadomość z załącznikiem nr 6.");
            }
        }
Beispiel #26
0
        public void ImmediateReply(object item, SendCondition condition)
        {
            Microsoft.Office.Interop.Outlook.MailItem mailItem = item as Microsoft.Office.Interop.Outlook.MailItem;
            if (mailItem == null)
            {
                throw new Exception("ImmediateReply: mailItem is undefined.");
            }


            string body = CreateResponseBody(mailItem.Subject.ToLower(), mailItem.Sender.Name, condition);


            if (body == null)
            {
                return;
            }

            Microsoft.Office.Interop.Outlook.MailItem reply = mailItem.ReplyAll();
            reply.HTMLBody = AdjustText(reply.HTMLBody);

            reply.HTMLBody = body + reply.HTMLBody;

            reply.Attachments.Add(this.attachmentFileName);

            if (condition == SendCondition.Conditional)
            {
                reply.Display();
            }
            else
            {
                reply.Send();
            }

            //mailItem.HTMLBody = string.Format( "<font size='1' color='red'><div id='replysent' > Reply sent on: {0}</div><font><br>", System.DateTime.Now.ToShortDateString() ) + mailItem.HTMLBody;
            //font-size:14px; font-family:Times New Roman;
            mailItem.HTMLBody = string.Format("<div id='replysent' style='color:darkblue; font-size:8px; font-family:Times New Roman;' > Reply sent on: {0}</div><br>", System.DateTime.Now.ToShortDateString()) + mailItem.HTMLBody;
        }
Beispiel #27
0
        protected void EnvoiMail_Click1(object sender, EventArgs e)
        {
            //Creation du fichier texte et stocakge dans les docs de l'utilisateur
            //récupéraiton des infos du questionnaire
            string Nom          = "Nomclient:" + TxbNomClient.Text;
            string Matiere      = "Matiere:" + TxbMatiere.Text;
            string Volume       = "Volume:" + TxbVolume.Text + ListVolume.Text;
            string Prix         = "Prix:" + TxbPrix.Text + ListePrix.Text;
            string Produitconnu = "Connu:" + RdbProduit.SelectedValue;
            string Danger       = "Danger:" + RdbDanger.SelectedValue;
            string Compositon   = "Compositon:" + TxbCompo.Text;
            string Objectif     = "Objectif:" + TxbObjectif.Text;
            string Raison       = "Raison:" + TxbRaison.Text;



            string[] lines = { Nom, Matiere, Volume, Prix, Produitconnu, Danger, Compositon, Objectif, Raison };

            // Set a variable to the My Documents path.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // Write the string array to a new file named "WriteLines.txt".
            using (StreamWriter outputFile = new StreamWriter(mydocpath + @"\DemandeEssai.txt"))
            {
                foreach (string line in lines)
                {
                    outputFile.WriteLine(line);
                }
            }



            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);

            //Outlook.MailItem mailItem = (Outlook.MailItem)
            //        this.Application.CreateItem(Outlook.OlItemType.olMailItem);

            mailItem.Subject = "This is the subject";
            mailItem.To      = "*****@*****.**";
            mailItem.Body    = "This is the message.";



            mailItem.Attachments.Add(mydocpath + @"\DemandeEssai.txt");//logPath is a string holding path to the log.txt file
            //mailItem.Importance = Outlook.OlImportance.olImportanceHigh;
            mailItem.Display(false);
            mailItem.Send();
            //.Send(mailItem);
            //((app._MailItem)mailItem).Send();

            //Popup de validation de l'envoi du mail et de la pièce jointe
            lblmessage.Text     = "Votre demande d'essai a été transmise par mail via votre boite outlook.";
            divThankYou.Visible = true;

            //Onvide tout les champs de DE
            TxbNomClient.Text = "";
            TxbMatiere.Text   = "";
            TxbVolume.Text    = "";
            TxbPrix.Text      = "";
            TxbCompo.Text     = "";
            TxbObjectif.Text  = "";
            TxbRaison.Text    = "";
        }