Microsoft.Protocols.TestSuites.MS_ASCAL.TestSuiteHelper.CreateMeetingRequestMime C# (CSharp) Method

CreateMeetingRequestMime() static private method

Create a meeting request mime
static private CreateMeetingRequestMime ( string from, string to, string subject, string body, string icalendarContent ) : string
from string The from address of mail
to string The to address of the mail
subject string The subject of the mail
body string The body content of the mail
icalendarContent string The content of iCalendar required by this meeting
return string
        internal static string CreateMeetingRequestMime(string from, string to, string subject, string body, string icalendarContent)
        {
            string meetingRequestMime =
@"From: {0}
To: {1}
Subject: {2}
Content-Type: multipart/alternative;
    boundary=""_001_MSASCAL_""
MIME-Version: 1.0

--_001_MSASCAL_
Content-Type: text/plain; charset=""us-ascii""

{3}

--_001_MSASCAL_
Content-Type: text/calendar; charset=""us-ascii""; method=REQUEST

{4}

--_001_MSASCAL_--

";
            return Common.FormatString(meetingRequestMime, from, to, subject, body, icalendarContent);
        }

Usage Example

        /// <summary>
        /// Using mail with mime content to send a meeting request or cancel request
        /// </summary>
        /// <param name="calendarItem">Calendar information</param>
        /// <param name="subjectName">The subject name of meeting request mail</param>
        /// <param name="organizerEmailAddress">The organizer email address</param>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="method">Specify normal appointments from meeting requests, responses, and cancellations, it can be set to 'REQUEST', 'REPLY', or 'CANCEL'</param>
        /// <param name="replyMethod">Specify REPLY method, it can be set to 'ACCEPTED', 'TENTATIVE', or 'DECLINED'</param>
        protected void SendMimeMeeting(Calendar calendarItem, string subjectName, string organizerEmailAddress, string attendeeEmailAddress, string method, string replyMethod)
        {
            string icalendarContent = string.Empty;

            switch (method.ToUpper(CultureInfo.CurrentCulture))
            {
            case "REQUEST":
            case "CANCEL":
                icalendarContent = TestSuiteHelper.CreateiCalendarFormatContent(calendarItem, method, replyMethod, organizerEmailAddress, attendeeEmailAddress);
                break;

            case "REPLY":
                icalendarContent = TestSuiteHelper.CreateiCalendarFormatContent(calendarItem, method, replyMethod, attendeeEmailAddress, organizerEmailAddress);
                break;
            }

            string body = string.Empty;

            string mime = TestSuiteHelper.CreateMeetingRequestMime(
                organizerEmailAddress,
                attendeeEmailAddress,
                subjectName,
                body,
                icalendarContent);

            // Send a meeting request
            SendMailRequest  sendMailRequest  = TestSuiteHelper.CreateSendMailRequest(TestSuiteHelper.Next(), false, mime);
            SendMailResponse sendMailResponse = this.CALAdapter.SendMail(sendMailRequest);

            Site.Assert.AreEqual <string>(
                string.Empty,
                sendMailResponse.ResponseDataXML,
                "The server should return an empty xml response data to indicate SendMail command success.");
        }