private void btnNewOutlook_Click(object sender, EventArgs e)
        {
            using (var outlook = new STC.Automation.Office.Outlook.Application())
            {
                MessageBox.Show(outlook.Version.ToString());

                using (var myNameSpace = outlook.GetNameSpace("MAPI"))
                {
                    using (var folder = myNameSpace.GetDefaultFolder(STC.Automation.Office.Outlook.Enums.DefaultFolders.Outbox))
                        folder.Display();
                }

                CreateEmail(outlook);
                //outlook.Quit();
            }
        }
 private void CreateEmail(STC.Automation.Office.Outlook.Application outlook)
 {
     using (var msg = (STC.Automation.Office.Outlook.MailItem)outlook.CreateItem(STC.Automation.Office.Outlook.Enums.ItemType.MailItem))
     {
         using (var recipient = msg.Recipients.Add("*****@*****.**"))
             recipient.Type = (long)STC.Automation.Office.Outlook.Enums.MailRecipientType.To;
         using (var recipient = msg.Recipients.Add("*****@*****.**"))
             recipient.Type = (long)STC.Automation.Office.Outlook.Enums.MailRecipientType.CC;
         msg.Subject    = "This is the subject";
         msg.Body       = "This is the body of the email.";
         msg.Importance = STC.Automation.Office.Outlook.Enums.Importance.High;
         if (File.Exists(@"C:\test.txt"))
         {
             using (var attachment = msg.Attachments.Add(@"C:\test.txt"));
         }
         msg.Recipients.ResolveAll();
         msg.Display();
         msg.Save();
         //msg.Send();
     }
 }
Beispiel #3
0
        private void btnNewOutlook_Click(object sender, EventArgs e)
        {
            using (var outlook = new STC.Automation.Office.Outlook.Application())
            {
                MessageBox.Show(outlook.Version.ToString());

                using (var myNameSpace = outlook.GetNameSpace("MAPI"))
                {
                    using (var folder = myNameSpace.GetDefaultFolder(STC.Automation.Office.Outlook.Enums.DefaultFolders.Outbox))
                        folder.Display();
                }

                CreateEmail(outlook);
                //outlook.Quit();
            }

        }