private static SmtpMessage CreateTestMessage1() { var msg = new SmtpMessage(); msg.Id = Guid.Parse("0a09ebcdd3544646b72325c743474a26"); msg.MailFrom = "*****@*****.**"; msg.Headers.Add("Content-Type", "multipart/mixed; charset=us-ascii; boundary=--boundary--"); msg.Headers.Add("Content-Transfer-Encoding", "7bit"); msg.Headers.Add("From", "*****@*****.**"); msg.Headers.Add("To", @"""Hanako"" <*****@*****.**>, ""Jiro"" <*****@*****.**>"); msg.Headers.Add("Date", "2 Jan 2014 20:23:13 +0900"); msg.Headers.Add("Subject", "[HELLO WORLD]"); msg.MailFrom = "*****@*****.**"; msg.RcptTo.Add("*****@*****.**"); msg.RcptTo.Add("*****@*****.**"); msg.Data.AddRange(new[] { "----boundary--", "Content-Type: text/plain; charset=us-ascii", "Content-Transfer-Encoding: 7bit", "", "Hello, World.", "----boundary--", "Content-Type: text/plain; charset=us-ascii; name=hello-world.txt", "Content-Transfer-Encoding: 7bit", "Content-Disposition: -", "", "Hello, World.", "----boundary----" }); msg.Attachments.Count().Is(1); return(msg); }
private static void Assert_SmtpMessage(SmtpMessage msg) { msg.Headers.Select(h => h.Key).OrderBy(k => k).Is( "Content-Transfer-Encoding", "Content-Type", "Date", "From", "Subject", "To"); msg.Headers.ValueOf("Content-Type").Is("multipart/mixed; charset=us-ascii; boundary=--boundary--"); msg.Headers.ValueOf("Content-Transfer-Encoding").Is("7bit"); msg.Headers.ValueOf("From").Is("*****@*****.**"); msg.Headers.ValueOf("To").Is(@"""Hanako"" <*****@*****.**>, ""Jiro"" <*****@*****.**>"); msg.Headers.ValueOf("Date").Is("2 Jan 2014 20:23:13 +0900"); msg.Headers.ValueOf("Subject").Is("[HELLO WORLD]"); msg.Data.Is( "----boundary--", "Content-Type: text/plain; charset=us-ascii", "Content-Transfer-Encoding: 7bit", "", "Hello, World.", "----boundary--", "Content-Type: text/plain; charset=us-ascii; name=hello-world.txt", "Content-Transfer-Encoding: 7bit", "Content-Disposition: -", "", "Hello, World.", "----boundary----"); }
public void Subject_Iso2022jp_QuotedPrintable_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Subject", "=?iso-2022-jp?Q?=1B=24B=243=24s=24K=24A=24O=40=243=26=1B=28B?="); msg.Subject.Is("こんにちは世界"); }
public void sendMail(AddressCollection recipients, String bodyHTML, String subject = "", AddressCollection CC = null, AddressCollection BCC = null, List <ExtraFile> attachments = null) { this.CheckRecipients(recipients); SmtpMessage newMail = new SmtpMessage(); this.SetMailSender(newMail); Sender.SetMailBody(bodyHTML, newMail); Sender.SetMailRecipients(recipients, subject, CC, BCC, newMail); Sender.SetMailAttachments(attachments, newMail); try { newMail.SendSsl("smtp.gmail.com", 465, this.senderAddress, CryptoHelper.DecryptDefaultKey(this.password), SaslMechanism.Login); } catch (SmtpException exc) { if (exc.Message.Contains("Command \"rcpt to: ") && exc.Message.Contains(" failed")) { throw new InvalidRecipientsException("La direccion " + this.ParseWrongReceipt(exc.Message) + " no es valida.", exc); } else { throw; } } }
public void Subject_Iso2022jp_Base64_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Subject", "=?iso-2022-jp?B?GyRCJDMkcyRLJEEk?=", "=?iso-2022-jp?B?T0AkMyYbKEI=?="); msg.Subject.Is("こんにちは世界"); }
private async void SendNewsletter(object sender, RoutedEventArgs e) { string to = String.Empty; var smtpServer = "smtp.gmail.com"; var port = 465; var from = "*****@*****.**"; var pwd = "vmasters28b"; var allEmails = _userManager.GetAllEmails(); to = allEmails.Aggregate(to, (current, email) => current + (email + ";")); var subject = Subject.Text; var body = Body.Text; var client = new SmtpClient(smtpServer, port, from, pwd, true); var message = new SmtpMessage(from, to, null, subject, body); try { await client.SendMail(message); Subject.Text = String.Empty; Body.Text = String.Empty; } catch (Exception ex) { var messageDialog = new MessageDialog("Something went wrong! Please try again later."); messageDialog.ShowAsync(); } }
public void MultipleServerPortSimple() { int ALT_PORT = 2525; // Start second server server2 = SimpleSmtpServer.Start(ALT_PORT); // Send to first server System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the subject", "This is the body."); // Check first server Assert.AreEqual(1, server.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email = server.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email.Headers["From"]); Assert.AreEqual("text/plain;", email.Headers["Content-Type"]); Assert.AreEqual("This is the subject", email.Headers["Subject"]); Assert.AreEqual("This is the body.", email.Body); // Check second server Assert.AreEqual(0, server2.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(0, server2.ReceivedEmailCount, "server.ReceivedEmailSize"); }
public void SendTwoMessages() { System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the subject", "This is the body."); System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the second subject", "This is the second body."); Assert.AreEqual(2, server.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(2, server.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email1 = server.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email1.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email1.Headers["From"]); Assert.AreEqual("text/plain;", email1.Headers["Content-Type"]); Assert.AreEqual("This is the subject", email1.Headers["Subject"]); Assert.AreEqual("This is the body.", email1.Body); SmtpMessage email2 = server.ReceivedEmail[1]; Assert.AreEqual("<*****@*****.**>", email2.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email2.Headers["From"]); Assert.AreEqual("text/plain;", email2.Headers["Content-Type"]); Assert.AreEqual("This is the second subject", email2.Headers["Subject"]); Assert.AreEqual("This is the second body.", email2.Body); }
/// <summary> /// Send an email from this application /// </summary> /// <param name="to">Destination address</param> /// <param name="subject">Message Subject</param> /// <param name="body">Message body</param> public static void SendEmail(string to, string subject, string body) { var settings = System.Configuration.ConfigurationManager.AppSettings; // We create the message object var message = new SmtpMessage(); // We assign the sender email from application settings message.From.Email = settings["AppEmailFrom"]; // We assign the message message.To.Add(to); message.Subject = subject; message.BodyText.Text = body; try { message.Send(host: settings["AppEmailSmtpHost"], username: settings["AppEmailUser"], password: settings["AppEmailPassword"], mechanism: SaslMechanism.CramMd5); } catch (Exception ex) { Trace.TraceError("Error While sending notfication to supervisor " + ex.Message); } }
public static void SendEmail(string[] emailAddresses, string body, string subject) { try { using (var client = new SmtpServiceClient("basicHttpEndPoint")) { var oMessage = new SmtpMessage { From = AppConfig.FromAddress, Body = body, IsBodyHtml = true, Subject = subject, To = emailAddresses.ToArray() }; try { client.Send2(oMessage); } catch (Exception exception) { LogEvent(exception, EventLogEntryType.Error); } } } catch (Exception exception) { LogEvent(exception, EventLogEntryType.Error); } }
public void Load_Test() { var msg = new SmtpMessage(); msg.Load(PathOf("expected.eml")); Assert_SmtpMessage(msg); }
private void ExpectEmailWithSubject_andBody_sentTo(String subject, String body, String recipient) { SmtpMessage message = emailIterator.First(); Assert.AreEqual(body, message.Body.Trim()); Assert.AreEqual(subject, message.Headers["Subject"]); Assert.AreEqual(recipient, message.Headers["To"]); }
public void From_AddressOnly_NoBlacket_Test() { var msg = new SmtpMessage(); msg.Headers.Add("From", "*****@*****.**"); msg.From.DisplayName.Is(""); msg.From.Address.Is("*****@*****.**"); }
public void From_Iso2022jp_Base64_Test() { var msg = new SmtpMessage(); msg.Headers.Add("From", "=?iso-2022-jp?B?GyRCRnxLXDhsGyhCIBskQkJATzobKEI=?= <*****@*****.**>"); msg.From.DisplayName.Is("日本語 太郎"); msg.From.Address.Is("*****@*****.**"); }
public void From_Ascii_7bit_Test() { var msg = new SmtpMessage(); msg.Headers.Add("From", "Mr.Anderson <*****@*****.**>"); msg.From.DisplayName.Is("Mr.Anderson"); msg.From.Address.Is("*****@*****.**"); }
public void Date_Test() { var msg = new SmtpMessage(); msg.Date.IsNull(); msg.Headers.Add("Date", "2 Jan 2014 20:23:13 +0900"); msg.Date.Is(DateTime.Parse("2014/1/2 20:23:13 +0900")); }
public SmtpMessage ReceiveResetEmail() { SmtpMessage resetEmailReceived = _server.ReceivedEmail.FirstOrDefault( x => x.ToAddresses[0].Address == "*****@*****.**" && x.Headers["Subject"] == "Password Reset"); _server.Stop(); return(resetEmailReceived); }
static ReceivedMail From(SmtpMessage smtpMessage) { var fromAddress = smtpMessage.FromAddress.Address; var toAddress = smtpMessage.ToAddresses.Single().Address; var subject = smtpMessage.Headers["Subject"]; var messagePart = smtpMessage.MessageParts.Single(); var body = messagePart.BodyData; return(new ReceivedMail(fromAddress, toAddress, subject, body)); }
public void CC_Test() { var msg = new SmtpMessage(); msg.Headers.Add("CC", @"""Mr.Anderson"" <*****@*****.**>, ""Mrs.Oracle"" <*****@*****.**>"); msg.CC.Select(_ => _.DisplayName) .Is("Mr.Anderson", "Mrs.Oracle"); msg.CC.Select(_ => _.Address) .Is("*****@*****.**", "*****@*****.**"); }
private void SetMailSender(SmtpMessage newMail) { if (this.senderName != null) { newMail.From = new ActiveUp.Net.Mail.Address(this.senderAddress, this.senderName); } else { newMail.From = new ActiveUp.Net.Mail.Address(this.senderAddress); } }
public void CharSet_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=us-ascii"); msg.Headers.GetCharSet().Is("us-ascii"); msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=\"ISO-2022-JP\""); msg.Headers.GetCharSet().Is("ISO-2022-JP"); }
public Email(SmtpMessage smtpMessage, int index, bool withoutRawData = false) { MailMessage mailMessage = Helpers.MailMessageMimeParser.ParseMessage(new StringReader(smtpMessage.Data)); Id = index; From = mailMessage.From.Address; To = string.Join("; ", mailMessage.To); Cc = string.Join("; ", mailMessage.CC); Bcc = GetBcc(smtpMessage, mailMessage); SentDate = mailMessage.Headers["Date"].AsDateTime(); Subject = mailMessage.Subject; Body = mailMessage.Body; RawData = withoutRawData ? "" : smtpMessage.Data; IsBodyHtml = mailMessage.IsBodyHtml; switch (smtpMessage.Importance) { case "high": Importance = "High"; break; case "low": Importance = "Low"; break; default: Importance = "Normal"; break; } Attachments = new List <Attachment>(); for (var i = 0; i < mailMessage.Attachments.Count; i++) { var attachment = new Attachment { Id = i + 1, Name = mailMessage.Attachments[i].ContentType.Name, ContentStream = (MemoryStream)mailMessage.Attachments[i].ContentStream }; attachment.SetSize(attachment.ContentStream.Capacity); Attachments.Add(attachment); } }
public void EXP_Send_Mail_With_Attachments_Sends_Correctly() { SmtpMessage newMail = new SmtpMessage(); String attachmentPath = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory) .Parent.Parent.FullName + "\\MailInterfaces\\ReadSign.jpg"; newMail.To.Add(new Address("*****@*****.**")); newMail.BodyText.Text = "Mail with attachment!"; newMail.Attachments.Add(attachmentPath, false); this.mySender.sendMail(newMail); Assert.Pass(); }
public void Body_Ascii_QuotedPrintable_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=us-ascii"); msg.Headers.Add("Content-Transfer-Encoding", "quoted-printable"); msg.Data.Add("Lorem \"ipsum\" 'dolor' =0D=0A="); msg.Data.Add("\tmagna aliqua="); msg.Data.Add(".. laborum.=20"); msg.Body.Is( "Lorem \"ipsum\" 'dolor' \r\n" + "\tmagna aliqua. laborum. "); }
public void sendConnectionMail(Object stateInfo, XElement cradle, string email) { SmtpMessage mail = new SmtpMessage(); mail.Subject = "CloudScan Connection Failure - " + cradle.Element("id").Value; mail.BodyHtml.Text = "<html><body style='font-family:Arial; font-size:10pt;'><h1>CloudScan connection failure for " + cradle.Element("id").Value + "</h1> <b>Mode: </b>" + cradle.Element("status").Element("mode").Value + "<br><b>Status: </b>" + cradle.Element("status").Element("description").Value + "</body></html>"; mail.From = new Address("*****@*****.**"); mail.To.Add(new Address(email)); mail.BuildMimePartTree(); mail.DirectSend(); }
public void MultipleServerPort() { int ALT_PORT = 2525; // Start second server server2 = SimpleSmtpServer.Start(ALT_PORT); // Send to first server System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the subject", "This is the body."); // Send to second server MailMessage mail = new MailMessage(); mail.To = "*****@*****.**"; mail.From = "*****@*****.**"; mail.Subject = "This is the second subject"; mail.Body = "This is the second body."; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", ALT_PORT.ToString()); SmtpMail.Send(mail); // Check first server Assert.AreEqual(1, server.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email = server.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email.Headers["From"]); Assert.AreEqual("text/plain;", email.Headers["Content-Type"]); Assert.AreEqual("This is the subject", email.Headers["Subject"]); Assert.AreEqual("This is the body.", email.Body); // Check second server Assert.AreEqual(1, server2.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server2.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email1 = server2.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email1.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email1.Headers["From"]); Assert.AreEqual("text/plain;", email1.Headers["Content-Type"]); Assert.AreEqual("This is the second subject", email1.Headers["Subject"]); Assert.AreEqual("This is the second body.", email1.Body); }
public void sendMail(Object stateInfo, XElement result, string email) { SmtpMessage mail = new SmtpMessage(); mail.Subject = "CloudScan Test Failure - " + result.Element("deviceName").Value; mail.BodyHtml.Text = "<html><body style='font-family:Arial; font-size:10pt;'><h1>CloudScan failed for " + result.Element("deviceName").Value + "</h1> <b>Device ID: </b>" + result.Element("deviceId").Value + "<br><b>Error: </b>" + result.Element("finalResult").Element("execution").Element("output").Element("status").Element("description").Value + "</body></html>"; mail.From = new Address("*****@*****.**"); mail.To.Add(new Address(email)); mail.BuildMimePartTree(); mail.DirectSend(); }
public void Load_with_Attachment_Test() { var msg = SmtpMessage.CreateFrom(PathOf("mail-with-attachment.eml")); var body = msg.Body; msg.Attachments.Count().Is(2); msg.Attachments[0].Name.Is("Markdown Presenter.pdf"); msg.Attachments[0].ContentBytes .Is(File.ReadAllBytes(PathOf("Markdown Presenter.pdf"))); msg.Attachments[1].Name.Is("花.jpg"); msg.Attachments[1].ContentBytes .Is(File.ReadAllBytes(PathOf("花.jpg"))); }
private static void SetMailBody(String bodyHTML, SmtpMessage newMail) { if (bodyHTML != null) { newMail.BodyHtml.Text = bodyHTML; newMail.BodyText.Text = newMail.BodyHtml.TextStripped; } else { newMail.BodyHtml.Text = newMail.BodyText.Text = " "; } SetMailBodyEncoding(newMail.BodyHtml, BodyFormat.Html); SetMailBodyEncoding(newMail.BodyText, BodyFormat.Text); }
public void CompanyInformationIsPresentInEmail() { MailService testedService = new MailService("localhost"); testedService.SendMail(new MailAddress("*****@*****.**"), "Dear customer", "We care!"); Assert.AreEqual(1, smtpServer.ReceivedEmailCount); SmtpMessage sentMail = (SmtpMessage)smtpServer.ReceivedEmail[0]; Assert.AreEqual("*****@*****.**", sentMail.FromAddress.ToString()); StringAssert.Contains(sentMail.Data, "Company Support"); }
public void Body_Iso2022jp_7bit_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=\"ISO-2022-JP\""); msg.Headers.Add("Content-Transfer-Encoding", "7bit"); msg.Data.AddRange(new[] { "\x1b$B$?$H$($P!\"0lCW$9$kI=;f!\"%X%C%@!<!\"%5%$%I%P!<$rDI2C$G$-$^$9!#\x1b(B", "[\x1b$BA^F~\x1b(B] \x1b$B$r%/%j%C%/$7$F$+$i!\"$=$l$>$l$N%.%c%i%j!<$GL\\E*$NMWAG$rA*$s$G$/$@$5$$!#\x1b(B", "", "\x1b$B%F!<%^$H%9%?%$%k$r;H$C$F!\"J8=qA4BN$NE}0l46$r=P$9$3$H$b$G$-$^$9!#\x1b(B" }); msg.Body.Is( "たとえば、一致する表紙、ヘッダー、サイドバーを追加できます。\r\n" + "[挿入] をクリックしてから、それぞれのギャラリーで目的の要素を選んでください。\r\n" + "\r\n" + "テーマとスタイルを使って、文書全体の統一感を出すこともできます。"); }
public void Body_MultiPart_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "multipart/mixed;", "boundary=--boundary_0_73bba9c5-516c-4f50-b880-a0d19568b806"); msg.Data.AddRange(new[] { "", "----boundary_0_73bba9c5-516c-4f50-b880-a0d19568b806", "Content-Type: text/plain; charset=iso-2022-jp", "Content-Transfer-Encoding: quoted-printable", "", "=1B$BF|K\\8l=1B(B", "----boundary_0_73bba9c5-516c-4f50-b880-a0d19568b806", "Content-Type: text/plain; charset=us-ascii; name=mytext.txt", "Content-Disposition: attachment", "Content-Transfer-Encoding: quoted-printable", "", "This is sample text", "----boundary_0_73bba9c5-516c-4f50-b880-a0d19568b806--", "", ""}); msg.Body.Is("日本語"); }
public void Date_Test() { var msg = new SmtpMessage(); msg.Date.IsNull(); msg.Headers.Add("Date", "2 Jan 2014 20:23:13 +0900"); msg.Date.Is(DateTime.Parse("2014/1/2 20:23:13")); }
private static SmtpMessage CreateTestMessage1() { var msg = new SmtpMessage(); msg.Id = Guid.Parse("0a09ebcdd3544646b72325c743474a26"); msg.MailFrom = "*****@*****.**"; msg.Headers.Add("Content-Type", "multipart/mixed; charset=us-ascii; boundary=--boundary--"); msg.Headers.Add("Content-Transfer-Encoding", "7bit"); msg.Headers.Add("From", "*****@*****.**"); msg.Headers.Add("To", @"""Hanako"" <*****@*****.**>, ""Jiro"" <*****@*****.**>"); msg.Headers.Add("Date", "2 Jan 2014 20:23:13 +0900"); msg.Headers.Add("Subject", "[HELLO WORLD]"); msg.MailFrom = "*****@*****.**"; msg.RcptTo.Add("*****@*****.**"); msg.RcptTo.Add("*****@*****.**"); msg.Data.AddRange(new[]{ "----boundary--", "Content-Type: text/plain; charset=us-ascii", "Content-Transfer-Encoding: 7bit", "", "Hello, World.", "----boundary--", "Content-Type: text/plain; charset=us-ascii; name=hello-world.txt", "Content-Transfer-Encoding: 7bit", "Content-Disposition: -", "", "Hello, World.", "----boundary----" }); msg.Attachments.Count().Is(1); return msg; }
public void To_Empty_Test() { var msg = new SmtpMessage(); msg.To.Count().Is(0); }
public void To_Test() { var msg = new SmtpMessage(); msg.Headers.Add("To", @"""Mr.Anderson"" <*****@*****.**>, ""Mrs.Oracle"" <*****@*****.**>"); msg.To.Select(_ => _.DisplayName) .Is("Mr.Anderson", "Mrs.Oracle"); msg.To.Select(_ => _.Address) .Is("*****@*****.**", "*****@*****.**"); }
public void Body_Utf8_Base64_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=\"utf-8\""); msg.Headers.Add("Content-Transfer-Encoding", "base64"); msg.Data.Add("44Gf44Go44GI44Gw44CB5LiA6Ie044GZ44KL6KGo57SZ44CB44OY44OD44OA44O844CB44K144Kk44OJ44OQ44O844KS6L+95Yqg"); msg.Data.Add("44Gn44GN44G+44GZ44CCW+aMv+WFpV0g44KS44Kv44Oq44OD44Kv44GX44Gm44GL44KJ44CB44Gd44KM44Ge44KM44Gu44Ku44Oj"); msg.Data.Add("44Op44Oq44O844Gn55uu55qE44Gu6KaB57Sg44KS6YG444KT44Gn44GP44Gg44GV44GE44CCDQrjg4bjg7zjg57jgajjgrnjgr/j"); msg.Data.Add("gqTjg6vjgpLkvb/jgaPjgabjgIHmlofmm7jlhajkvZPjga7ntbHkuIDmhJ/jgpLlh7rjgZnjgZPjgajjgoLjgafjgY3jgb7jgZnj"); msg.Data.Add("gII="); msg.Body.Is( "たとえば、一致する表紙、ヘッダー、サイドバーを追加できます。[挿入] をクリックしてから、それぞれのギャラリーで目的の要素を選んでください。\r\n" + "テーマとスタイルを使って、文書全体の統一感を出すこともできます。"); }
public void CC_Empty_Test() { var msg = new SmtpMessage(); msg.CC.Count().Is(0); }
public void Can_Serialize_Deserialize_as_Json_by_JsonNET_Minimum_Test() { var msg = new SmtpMessage(); msg.Headers.Add("Content-Type", "text/plain; charset=us-ascii"); msg.Headers.Add("Content-Transfer-Encoding", "7bit"); // Can serialize. var json = JsonConvert.SerializeObject(msg); Debug.WriteLine(json); // Can deserialize. var msg2 = JsonConvert.DeserializeObject<SmtpMessage>(json); msg2.MailFrom.IsNull(); msg2.RcptTo.Count().Is(0); msg2.Headers.OrderBy(h => h.Key).Select(h => new { h.Key, h.Value }.ToString()).Is( "{ Key = Content-Transfer-Encoding, Value = 7bit }", "{ Key = Content-Type, Value = text/plain; charset=us-ascii }"); msg2.Attachments.Count().Is(0); }
public void Attachment_Empty_Test() { var msg = new SmtpMessage(); msg.Attachments.Count().Is(0); }