当前位置: 首页>>代码示例>>C#>>正文


C# MailAddress.ToString方法代码示例

本文整理汇总了C#中MailAddress.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MailAddress.ToString方法的具体用法?C# MailAddress.ToString怎么用?C# MailAddress.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MailAddress的用法示例。


在下文中一共展示了MailAddress.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MailAddress

        public void MailAddress_WithUnicodeDisplayAndMailAddress_ToStringShouldReturnDisplayNameInQuotesAndAddressInAngleBrackets()
        {
            MailAddress _mailAddress = new MailAddress(Address, DisplayNameWithUnicode);
            Assert.Equal(_mailAddress.DisplayName, DisplayNameWithUnicode);

            Assert.Equal(string.Format("\"{0}\" <{1}>", DisplayNameWithUnicode, Address), _mailAddress.ToString());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:MailAddressDisplayNameTest.cs

示例2: SetUp

        public void SetUp()
        {
            init = new Initialization2();

            ml = init.CreateMl();

            user1 = new MailAddress("[email protected]");
            user2 = new MailAddress("[email protected]");
            //user3 = new MailAddress("[email protected]");
            user4 = new MailAddress("[email protected]");
            admin = new MailAddress("[email protected]");
            admin2 = new MailAddress("[email protected]");
            //mlCtrl = init.MlAddr.Ctrl;
            //mlPost = init.MlAddr.Post;
            mlAdmin = init.MlAddr.Admin;
            //mailDaemon = new MailAddress("[email protected]");
            user1Str = string.Format("\"USER1\" <{0}>", user1.ToString());
            //user2Str = string.Format("\"USER2\" <{0}>", user2.ToString());
            //user3Str = string.Format("\"USER3\" <{0}>", user3.ToString());
            user4Str = string.Format("\"USER4\" <{0}>", user4.ToString());
            //adminStr = string.Format("\"ADMIN\" <{0}>", admin.ToString());
            admin2Str = string.Format("\"ADMIN2\" <{0}>", admin2.ToString());
            mlCtrlStr = string.Format("\"1BAN(CTRL)\" <{0}>", init.MlAddr.Ctrl);
            mlPostStr = string.Format("\"1BAN\" <{0}>", init.MlAddr.Post);
            mlAdminStr = init.MlAddr.Admin.ToString();
            //mailDaemonStr = string.Format("\"Mail Delivery Subsystem\"<{0}>", mailDaemon.ToString());

            //init.MailSave.Clear();//初期化
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:29,代码来源:MlTotalTest.cs

示例3: TestConstructorOverload1

        public void TestConstructorOverload1()
        {
            address = new MailAddress(" [email protected] ");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal(string.Empty, address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("[email protected]", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("Mr. Foo Bar <[email protected]>");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("Mr. Foo Bar", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"Mr. Foo Bar\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("FooBar <[email protected]>");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("FooBar", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"FooBar\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("\"FooBar\"[email protected]   ");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("FooBar", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"FooBar\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("\"   FooBar   \"< [email protected] >");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("   FooBar   ", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"   FooBar   \" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("<[email protected]>");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal(string.Empty, address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("[email protected]", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("    <  [email protected]  >");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal(string.Empty, address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("[email protected]", address.ToString());
            Assert.Equal("foo", address.User);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:51,代码来源:MailAddressTest.cs

示例4: Comfirm

 //確認
 void Comfirm(int n, string fromStr, string toStr, MailAddress from, MailAddress to, string subject)
 {
     //エンベロープの確認
     Assert.AreEqual(init.TestMailSave.GetFrom(n).ToString(), from.ToString());
     Assert.AreEqual(init.TestMailSave.GetTo(n).ToString(), to.ToString());
     //ヘッダの確認
     var mail = init.TestMailSave.GetMail(n);
     Assert.AreEqual(mail.GetHeader("from"), fromStr);
     Assert.AreEqual(mail.GetHeader("to"), toStr);
     //件名
     Assert.AreEqual(mail.GetHeader("subject"), subject);
 }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:13,代码来源:MlTest.cs

示例5: MailAddress_WithNoDisplayName_AndOnlyAddress_ToStringShouldOutputAddressOnlyWithNoAngleBrackets

 public void MailAddress_WithNoDisplayName_AndOnlyAddress_ToStringShouldOutputAddressOnlyWithNoAngleBrackets()
 {
     MailAddress _mailAddress = new MailAddress(Address);
     Assert.Equal(Address, _mailAddress.ToString());
 }
开发者ID:dotnet,项目名称:corefx,代码行数:5,代码来源:MailAddressDisplayNameTest.cs

示例6: TestConstructorOverload2

        public void TestConstructorOverload2()
        {
            address = new MailAddress(" [email protected] ", null);
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal(string.Empty, address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("[email protected]", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("Mr. Far Bar <[email protected]>", "BarFoo");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("BarFoo", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"BarFoo\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("Mr. Far Bar <[email protected]>  ", string.Empty);
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("Mr. Far Bar", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"Mr. Far Bar\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("Mr. Far Bar <[email protected]>", null);
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal("Mr. Far Bar", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\"Mr. Far Bar\" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);

            address = new MailAddress("Mr. Far Bar <[email protected]>   ", " ");
            Assert.Equal("[email protected]", address.Address);
            Assert.Equal(" ", address.DisplayName);
            Assert.Equal("example.com", address.Host);
            Assert.Equal("\" \" <[email protected]>", address.ToString());
            Assert.Equal("foo", address.User);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:37,代码来源:MailAddressTest.cs

示例7: MailMessageWrapper

	// Constructor		
	public MailMessageWrapper( MailMessage message )
	{
	    this.message = message;
	    
	    if( message.From != null ) {
			from = MailAddress.Parse( message.From );
			header.From = from.ToString();
	    }
	    
	    if( message.To != null ) {
		to = MailAddressCollection.Parse( message.To );
		header.To = to.ToString();
	    }
	    
	    if( message.Cc != null ) {
		cc = MailAddressCollection.Parse( message.Cc );
		header.Cc = cc.ToString();
	    }
		
	    if( message.Bcc != null ) {
		bcc = MailAddressCollection.Parse( message.Bcc );
		header.Bcc = bcc.ToString();
	    }
   
	    // set the subject
	    if( message.Subject != null ) {
		
		// encode the subject if it needs encoding
		if( MailUtil.NeedEncoding( message.Subject ) ) {
		    		
		    byte[] subjectBytes = message.BodyEncoding.GetBytes( message.Subject );
		    // encode the subject with Base64
		    header.Subject = String.Format( "=?{0}?B?{1}?=" , 
						    message.BodyEncoding.BodyName ,
						    Convert.ToBase64String( subjectBytes ) );
		} else {
		    
		    header.Subject = message.Subject;
		
		}
	    }

	    // convert single '.' on a line with ".." to not
	    // confuse the smtp server since the DATA command
	    // is terminated with a '.' on a single line.
	    // this is also according to the smtp specs.
	    if( message.Body != null ) {
		body = message.Body.Replace( "\n.\n" , "\n..\n" );
		body = body.Replace( "\r\n.\r\n" , "\r\n..\r\n" );
	    }
	    
	    
	    // set the Contet-Base header
	    if( message.UrlContentBase != null ) 
		header.ContentBase = message.UrlContentBase;
	    
	    // set the Contet-Location header
	    if( message.UrlContentLocation != null ) 
		header.ContentLocation = message.UrlContentLocation;

	    	    
	    // set the content type
	    switch( message.BodyFormat ) {
		
	    case MailFormat.Html: 
		header.ContentType = 
		    String.Format( "text/html; charset=\"{0}\"" , message.BodyEncoding.BodyName ); 
		break;
	    
	    case MailFormat.Text: 
		header.ContentType = 
		    String.Format( "text/plain; charset=\"{0}\"" , message.BodyEncoding.BodyName );
		break;
	    
	    default: 
		header.ContentType = 
		    String.Format( "text/html; charset=\"{0}\"" , message.BodyEncoding.BodyName );
		break;
	    }
	    
	    	    
	    // set the priority as in the same way as .NET sdk does
	    switch( message.Priority ) {
		
	    case MailPriority.High: 
		header.Importance = "high";
		break;
	    
	    case MailPriority.Low: 
		header.Importance = "low";
		break;
		
	    case MailPriority.Normal: 
		header.Importance = "normal";
		break;
		
	    default: 
		header.Importance = "normal";
		break;
//.........这里部分代码省略.........
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:101,代码来源:MailMessageWrapper.cs


注:本文中的MailAddress.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。