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


C# MailAddressCollection.ToString方法代码示例

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


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

示例1: CreateMeetingRequest

    public static MailMessage CreateMeetingRequest(DateTime start, DateTime end, string subject, string summary,string location, string organizerName, string organizerEmail, MailAddressCollection attendeeList)
    {
        MailMessage msg = new MailMessage();
        //  Set up the different mime types contained in the message
        System.Net.Mime.ContentType textType = new System.Net.Mime.ContentType("text/plain");
        System.Net.Mime.ContentType HTMLType = new System.Net.Mime.ContentType("text/html");
        System.Net.Mime.ContentType calendarType = new System.Net.Mime.ContentType("text/calendar");
        //  Add parameters to the calendar header
        calendarType.Parameters.Add("method", "REQUEST");
        calendarType.Parameters.Add("name", "meeting.ics");
        //  Create message body parts
        //  create the Body in text format
        string bodyText = "Type:Single Meeting\r\nOrganizer: {0}\r\nStart Time:{1}\r\nEnd Time:{2}\r\nTime Zone:{3}\r\nLocation: {4}\r\n\r\n*~*~*~*~*~*~*~*~*~*\r\n\r\n{5}";
        bodyText = string.Format(bodyText,
            organizerName,
            start.ToLongDateString() + " " + start.ToLongTimeString(),
            end.ToLongDateString() + " " + end.ToLongTimeString(),
            System.TimeZone.CurrentTimeZone.StandardName,
            location,
            summary);

        AlternateView textView = AlternateView.CreateAlternateViewFromString(bodyText, textType);
        msg.AlternateViews.Add(textView);

        //create the Body in HTML format
        string bodyHTML = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\r\n<HTML>\r\n<HEAD>\r\n<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\r\n<META NAME=\"Generator\" CONTENT=\"MS Exchange Server version 6.5.7652.24\">\r\n<TITLE>{0}</TITLE>\r\n</HEAD>\r\n<BODY>\r\n<!-- Converted from text/plain format -->\r\n<P><FONT SIZE=2>Type:Single Meeting<BR>\r\nOrganizer:{1}<BR>\r\nStart Time:{2}<BR>\r\nEnd Time:{3}<BR>\r\nTime Zone:{4}<BR>\r\nLocation:{5}<BR>\r\n<BR>\r\n*~*~*~*~*~*~*~*~*~*<BR>\r\n<BR>\r\n{6}<BR>\r\n</FONT>\r\n</P>\r\n\r\n</BODY>\r\n</HTML>";
        bodyHTML = string.Format(bodyHTML,
            organizerName,
            start.ToLongDateString() + " " + start.ToLongTimeString(),
            end.ToLongDateString() + " " + end.ToLongTimeString(),
            System.TimeZone.CurrentTimeZone.StandardName,
            location,
            summary);

        AlternateView HTMLView = AlternateView.CreateAlternateViewFromString(bodyHTML, HTMLType);
        msg.AlternateViews.Add(HTMLView);

        //create the Body in VCALENDAR format
        string calDateFormat = "yyyyMMddTHHmmssZ";
        string bodyCalendar = "BEGIN:VCALENDAR\r\nMETHOD:REQUEST\r\nPRODID:Microsoft CDO for Microsoft Exchange\r\nVERSION:2.0\r\nBEGIN:VTIMEZONE\r\nTZID:(GMT-06.00) Central Time (US & Canada)\r\nX-MICROSOFT-CDO-TZID:11\r\nBEGIN:STANDARD\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTAMP:{8}\r\nDTSTART:{0}\r\nSUMMARY:{7}\r\nUID:{5}\r\nATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{9}\":MAILTO:{9}\r\nACTION;RSVP=TRUE;CN=\"{4}\":MAILTO:{4}\r\nORGANIZER;CN=\"{3}\":mailto:{4}\r\nLOCATION:{2}\r\nDTEND:{1}\r\nDESCRIPTION:{7}\\N\r\nSEQUENCE:1\r\nPRIORITY:5\r\nCLASS:\r\nCREATED:{8}\r\nLAST-MODIFIED:{8}\r\nSTATUS:CONFIRMED\r\nTRANSP:OPAQUE\r\nX-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\nX-MICROSOFT-CDO-INSTTYPE:0\r\nX-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\r\nX-MICROSOFT-CDO-ALLDAYEVENT:FALSE\r\nX-MICROSOFT-CDO-IMPORTANCE:1\r\nX-MICROSOFT-CDO-OWNERAPPTID:-1\r\nX-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:{8}\r\nX-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:{8}\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:REMINDER\r\nTRIGGER;RELATED=START:-PT00H15M00S\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
        bodyCalendar = string.Format(bodyCalendar,
            start.ToUniversalTime().ToString(calDateFormat),
            end.ToUniversalTime().ToString(calDateFormat),
            location,
            organizerName,
            organizerEmail,
            Guid.NewGuid().ToString("B"),
            summary,
            subject,
            DateTime.Now.ToUniversalTime().ToString(calDateFormat),
            attendeeList.ToString());

        AlternateView calendarView = AlternateView.CreateAlternateViewFromString(bodyCalendar, calendarType);
        calendarView.TransferEncoding = TransferEncoding.SevenBit;
        msg.AlternateViews.Add(calendarView);
        //Adress the message
        msg.From = new MailAddress(organizerEmail);
        foreach (MailAddress attendee in attendeeList)
        {
            msg.To.Add(attendee);
        }
        msg.Subject = subject;
        return msg;
    }
开发者ID:jigshGitHub,项目名称:SandlerTrainingDevelopment,代码行数:64,代码来源:Test.aspx.cs

示例2: ApplyMailAddressOverride

        /// <summary>
        /// Applies the override to a MailAddressCollection
        /// </summary>
        /// <param name="addresses">The addresses.</param>
        /// <returns></returns>
        protected MailAddressCollection ApplyMailAddressOverride(MailAddressCollection addresses)
        {
            if (clear)
            {
                addresses.Clear();
            }
            else
            {
                if (!string.IsNullOrEmpty(overrideString))
                {
                    addresses.Clear();
                    addresses.Add(overrideString);
                }

                if (!string.IsNullOrEmpty(prependString))
                {
                    var old = addresses.ToString();
                    addresses.Clear();
                    addresses.Add(prependString);
                    if(!string.IsNullOrWhiteSpace(old)) addresses.Add(old);
                }

                if (!string.IsNullOrEmpty(appendString))
                {
                    addresses.Add(appendString);
                }
            }

            return addresses;
        }
开发者ID:kmc059000,项目名称:trout.messagequeue,代码行数:35,代码来源:MailMessageOverride.cs

示例3: 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


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