From 113eaf4d8a37e212b8528d41e400b346ce9f51d2 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 8 May 2018 17:01:22 +0300 Subject: Added improvements to stubs UI. Implemented Bug Reporter engine! --- .../Visual_Studio/Tango.UnitTesting/Outlook_TST.cs | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/Tango.UnitTesting') diff --git a/Software/Visual_Studio/Tango.UnitTesting/Outlook_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Outlook_TST.cs index b34db8578..57a22dbd9 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Outlook_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Outlook_TST.cs @@ -2,7 +2,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net.Mail; using System.Text; using System.Threading.Tasks; using Outlook = Microsoft.Office.Interop.Outlook; @@ -14,7 +16,7 @@ namespace Tango.UnitTesting public class Outlook_TST { [TestMethod] - public void Send_Email_With_Logs() + public void Send_Email_With_Logs_Using_Outlook() { Application app = new Application(); MailItem email = (MailItem)app.CreateItem(OlItemType.olMailItem); @@ -31,5 +33,34 @@ namespace Tango.UnitTesting email.Importance = OlImportance.olImportanceNormal; email.Send(); } + + [TestMethod] + public void Send_Email_With_Logs_With_Outlook_SMTP() + { + String sender = "roy@twine-s.com"; + String recipient = "roy@twine-s.com"; + + SmtpClient client = new SmtpClient("smtp-mail.outlook.com"); + + client.Port = 587; + client.DeliveryMethod = SmtpDeliveryMethod.Network; + client.UseDefaultCredentials = false; + System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sender, "Maya2018"); + client.EnableSsl = true; + client.Credentials = credentials; + + try + { + var mail = new MailMessage(sender.Trim(), recipient.Trim()); + mail.Attachments.Add(new System.Net.Mail.Attachment(new FileStream("D:\\C#.txt", FileMode.Open), "C# Code")); + mail.Subject = "Test Email"; + mail.Body = "This is a test."; + client.Send(mail); + } + catch (System.Exception ex) + { + throw ex; + } + } } } -- cgit v1.3.1