locked
Not able to send meeting request with attachment using c# RRS feed

  • Question

  • Hi,

    I am able to send meeting request but without attachment, either the attachment goes or the meeting request. I also tried attaching the ics  file, but same problem again. If the attachment is send then the meeting request is broken/spoiled. It comes in the following format.

    BEGIN:VCALENDAR

    METHOD:REQUEST

    PRODID:Microsoft CDO for Microsoft Exchange

    VERSION:2.0

    BEGIN:VTIMEZONE

    TZID:(GMT-06.00) Central Time (US & Canada)

    X-MICROSOFT-CDO-TZID:11

    BEGIN:STANDARD

    DTSTART:16010101T020000

    TZOFFSETFROM:-0500

    TZOFFSETTO:-0600

    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU

    END:STANDARD

    BEGIN:DAYLIGHT

    • Moved by Kristin Xie Wednesday, February 11, 2015 9:38 AM
    Wednesday, February 4, 2015 6:35 AM

Answers

  • Hi harry,

    After take a look at your code, your case belong to Web form application. Please consider to post Asp.Net forum.

    Here is the link:http://forums.asp.net  Thanks for your understanding.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Just Karl Thursday, April 9, 2015 9:35 PM
    Wednesday, February 11, 2015 9:38 AM

All replies

  • Hello,

    please share more informations about your problem, i need to undrestand the project context to help you.

    • Proposed as answer by Bouzid Mohamed Wednesday, February 4, 2015 2:57 PM
    Wednesday, February 4, 2015 9:26 AM
  • Hi,

    I need to send a outlook  calendar meeting request with attachment using c# code, I am able to send meeting request but without attachment. If attachment is added either it is overwritten or the meeting request is over written and only the meeting request is spoiled.

    I have written a c# code which is sending the meeting request without attachment, just need to add the attachment as we add it while sending it with outlook. 

    Wednesday, February 4, 2015 10:50 AM
  • Probably the Visual Studio For Office is a better place to ask this question.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vsto


    Success
    Cor

    Wednesday, February 4, 2015 12:51 PM
  • Hi,

    I have a custom web form through which I am sending outlook meeting request to the attendees, need help on adding the attachment. I am doing it through C# code.

    This is my piece of code

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Security;
    using System.Text;
    using Microsoft.SharePoint;
    using System.Net.Mail;
    using System.Net;
    using System.Web;
    using System.Configuration;
    using System.Net.Mime;
    using System.IO;


    namespace Meeting.Meeting
    {
        public partial class MeetingUserControl : UserControl
        {

            protected void Page_Load(object sender, EventArgs e)
            {

            }

            protected void meeting()
            {

            }
            public void abc()
            {
                try
                {
                    MailMessage Message = new MailMessage();
                    System.Net.Mail.Attachment att;

                    att = new System.Net.Mail.Attachment(@"D:\Work\PERSONAL\Yogesh\AddSolution.txt");

                    Message.Attachments.Add(att);

                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }


            }

            private void sendMailMessage(MailMessage email)
            {
                throw new NotImplementedException();
            }


            protected void Button1_Click(object sender, EventArgs e)
            {
               abc();

                //Declaration a list of attendees
                MailAddressCollection macCollection = new MailAddressCollection();
                //Add attendde. In this example, I send invite to only one
                macCollection.Add(new MailAddress("mail address"));
                //add attachment

                //Create mail message
                MailMessage mmMessage = CreateMeetingRequest(DateTime.Now.AddHours(1), DateTime.Now.AddHours(2), "Test", "Test", "Test", "Yogesh", "mail address", macCollection);
                //Create smtp client
                SmtpClient smtp = new SmtpClient();
                smtp.Host = SPContext.Current.Web.Site.WebApplication.OutboundMailServiceInstance.Server.Address;
                //Configure your smtp client
                smtp.EnableSsl = false;
                // smtp.Credentials = new NetworkCredential("yourloginname", "password");
                //Send it

                smtp.Send(mmMessage);


            }


            public static MailMessage CreateMeetingRequest(DateTime dtStart, DateTime dtEnd, string strSubject, string strSummary,
            string strLocation, string strOrganizerName, string strOrganizerEmail,
                 MailAddressCollection macAttendeeList)
            {
                //Create an instance of mail message
                MailMessage mmMessage = new MailMessage();
                //  Set up the different mime types contained in the message
                System.Net.Mime.ContentType typeText = new System.Net.Mime.ContentType("text/plain");
                System.Net.Mime.ContentType typeHTML = new System.Net.Mime.ContentType("text/html");
                System.Net.Mime.ContentType typeCalendar = new System.Net.Mime.ContentType("text/calendar");


                //  Add parameters to the calendar header
                typeCalendar.Parameters.Add("method", "REQUEST");
                typeCalendar.Parameters.Add("name", "meeting.ics");


                           //Create the Body in VCALENDAR format
                string strCalDateFormat = "yyyyMMddTHHmmssZ";
                string strBodyCalendar = "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";
                strBodyCalendar = string.Format(strBodyCalendar, dtStart.ToUniversalTime().ToString(strCalDateFormat), dtEnd.ToUniversalTime().ToString(strCalDateFormat),
                strLocation, strOrganizerName, strOrganizerEmail, Guid.NewGuid().ToString("B"), strSummary, strSubject,
                DateTime.Now.ToUniversalTime().ToString(strCalDateFormat), macAttendeeList.ToString());
                AlternateView viewCalendar = AlternateView.CreateAlternateViewFromString(strBodyCalendar, typeCalendar);
                Attachment att = new Attachment(@"D:\Work\PERSONAL\Yogesh\AddSolution.txt");
                att.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
              
                viewCalendar.TransferEncoding = TransferEncoding.SevenBit;
                mmMessage.Attachments.Add(att);
                mmMessage.AlternateViews.Add(viewCalendar);


              
                mmMessage.From = new MailAddress(strOrganizerEmail);

                foreach (MailAddress attendee in macAttendeeList)
                {
                    mmMessage.To.Add(attendee);
                }
                mmMessage.Subject = strSubject;

                return mmMessage;
            }

            //public static string vCalPath { get; set; }

            //System.Net.Mail.Attachment att = new System.Net.Mail.Attachment(@"D:\Work\PERSONAL\Yogesh\AddSolution.ics");

        }
    }

    Thursday, February 5, 2015 6:49 AM
  • Hi harry,

    After take a look at your code, your case belong to Web form application. Please consider to post Asp.Net forum.

    Here is the link:http://forums.asp.net  Thanks for your understanding.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Just Karl Thursday, April 9, 2015 9:35 PM
    Wednesday, February 11, 2015 9:38 AM