本文整理汇总了C#中Mail.AddTo方法的典型用法代码示例。如果您正苦于以下问题:C# Mail.AddTo方法的具体用法?C# Mail.AddTo怎么用?C# Mail.AddTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail.AddTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetRcpts
public void TestGetRcpts()
{
var foo = new Mock<IHeader>();
var sg = new Mail(foo.Object);
sg.AddTo("[email protected]");
sg.AddCc("[email protected]");
sg.AddBcc("[email protected]");
sg.AddBcc("[email protected]");
var rcpts = sg.GetRecipients();
Assert.AreEqual("[email protected]", rcpts.First(), "getRecipients check To");
Assert.AreEqual("[email protected]", rcpts.Skip(1).First(), "getRecipients check Cc");
Assert.AreEqual("[email protected]", rcpts.Skip(2).First(), "getRecipients check Bcc");
Assert.AreEqual("[email protected]", rcpts.Skip(3).First(), "getRecipients check Bcc x2");
}
示例2: TestAddTo
public void TestAddTo()
{
var foo = new Mock<IHeader>();
var sg = new Mail(foo.Object);
sg.AddTo("[email protected]");
Assert.AreEqual("[email protected]", sg.To.First().ToString(), "Single To Address" );
sg = new Mail(foo.Object);
var strings = new String[2];
strings[0] = "[email protected]";
strings[1] = "[email protected]";
sg.AddTo(strings);
Assert.AreEqual("[email protected]", sg.To[0].ToString(), "Multiple To addresses, check first one");
Assert.AreEqual("[email protected]", sg.To[1].ToString(), "Multiple To addresses, check second one");
sg = new Mail(foo.Object);
var a = new Dictionary<String, String>();
a.Add("DisplayName", "Eric");
var datastruct = new Dictionary<string, IDictionary<string, string>> {{"[email protected]", a}};
sg.AddTo(datastruct);
Assert.AreEqual("Eric", sg.To.First().DisplayName, "Single address with args");
}