aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Outlook_TST.cs33
1 files changed, 32 insertions, 1 deletions
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;
+ }
+ }
}
}