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

  • Question

  • Hi

    We are sending vcal using SMTP which display in Outlook perfectly. When we are trying to send attachment it is not  showing attachment in vcal below code i used 

     AlternateView calendarView = AlternateView.CreateAlternateViewFromString(bodyCalendar, "text/calendar; method=REQUEST; name=meeting.ics");
                                    calendarView.TransferEncoding = TransferEncoding.QuotedPrintable;
                                    msg.AlternateViews.Add(calendarView);  

    where bodyCalendar is vcal body with attachment

    BEGIN:VCALENDAR
    PRODID:-//Workspace
    VERSION:2.0
    METHOD:REQUEST
    X-MS-OLK-FORCEINSPECTOROPEN:TRUE
    BEGIN:VTIMEZONE
    TZID:GMT Standard Time
    BEGIN:STANDARD
    DTSTART:20171029T020000
    RRULE:FREQ=YEARLY;BYDAY=5SU;BYMONTH=10
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0000
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:20170326T010000
    TZOFFSETFROM:+0000
    TZOFFSETTO:+0100
    RRULE:FREQ=YEARLY;BYDAY=4SU;BYMONTH=3
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VEVENT
    ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME="1acf251b-82c2-4296-a680-36ecdf15cc0a_Holidays for Pune 2018.pdf":T09QUw0KCTEuIHZhbHVlIHR5cGUgYW5kIHJlZnJlbmNlIHR5cGUNCgkyLiBHQw0KCTMuIEluaGVyaXRhbmNlDQoJNC4gUnVuZSB0aW1lIHBvbHkNCgk2LiBBYnN0YWN0IHZzIEVuY2FwICYgaW50ZXJmYWNlIFZzIGFic3RyYWN0DQoNCkFTUC5uZXQvTVZDOiANCjEuIEx5ZmljZSBjeWFjbGUNCjIuIFJlcXVlc3QgbGlmZSBjeWFjbGUNCjMuIEFTUC5uZXQgdnMgTVZDDQo0LiBGaWx0ZXINCjUuIEhUVFAgaGFuZGxlcg0KNi4gU2Vzc2lvbiBtYW5nZW1lbnQgDQo3LiBGaWx0ZXINCjguIEF1dGhlbml0aWNhdGlvbg0KMTAuIGh0bXBhY3RpbiB2cyBodG0ucmVuZGVycGFydGlvYWwgIA0KDQpKUXVlcnk6IGNvZGUgdG8gd3JpdGUNCndoYXQgeW91IHVlc2VkDQpkaWZmZXJlbnQgc2VsZWN0b3INCkpxdWVyeSB2cyBhamF4DQpBbmp1bGFyanM6DQpVc2UgcGFnZSByZXF1ZXN0DQppbml0DQpGaWx0ZXINCg0KDQpTUUw6DQoNCg0KV0NGL1dlYkFQSToNCmRpZmZlcmVuY2UNClRyYW5hY3Rpb24NClNxdWVyaXR5DQoNCg0KDQoNClNRTDoNCg0KDQoNCg0KDQpHZW5hcmFsOg0KQW5vbnltb3VzIHR5cGUNCllpZWxkDQpSZWYgdnMgT1VUDQpTT2xpZCBQcmluY2lwbGUNCg0K
    DTSTART;TZID="GMT Standard Time":20171218T164500
    DTSTAMP:20171218T122759Z
    DTEND;TZID="GMT Standard Time":20171218T174500
    LOCATION:4-404 (Max 14)
    CATEGORIES:VcalWorkspace
    SEQUENCE:3
    UID:9e09304a-5edf-4523-9f28-ce3317a4936b
    DESCRIPTION:Meeting invitation:\n
    X-ALT-DESC;FMTTYPE=text/html:Meeting invitation:<br/>
    SUMMARY:dasd
    ORGANIZER:MAILTO:georgeg@nfstechgroup.com
    ATTENDEE;CN="neerajb@nfstechgroup.com";RSVP=TRUE:mailto:neerajb@nfstechgroup.com
    BEGIN:VALARM
    TRIGGER:-PT15M
    ACTION:DISPLAY
    DESCRIPTION:Reminder
    END:VALARM
    END:VEVENT
    END:VCALENDAR

    Why it not showing attachment when sent using SMTP?

    Observation:

    Observation: When same vcal body(above) copy in text file and save as ics and open in outlook it shows attachment

    Please help..

    When same vcal body(above) copy in text file and save as ics and open in outlook it shows attachment

    Please help..


    Neeraj

    • Moved by Chenchen Li Tuesday, December 19, 2017 3:32 AM NotOOB
    Monday, December 18, 2017 2:19 PM

All replies

  • Hello Neerajb,

    This forum(Visual Studio for Office) is for development issue related to Office Object Model and your issue is more related to System.Net library, so I would move this thread to Network Class Library (System.Net) forum. Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 19, 2017 3:29 AM
  • Hi Neerajb,

    Thank you for posting here.

    For your question, what is the type of your project? Please provide the sample code for us to test.

    If you want to send attachment using SMTP, you would like to check the MSDN article.

    According to the code you provided, the calendarView is from UWP API reference. 

    https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.calendarview

    Please provide more information about your question. It would be better if you have the picture showing the results.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 20, 2017 8:28 AM
    Moderator
  • Please find working below code 

    SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);NetworkCredential networkCredential = new NetworkCredential("nfsindiallp@gmail.com", "nfsindia@403");sc.Credentials = networkCredential; sc.EnableSsl = true;MailMessage msg = new MailMessage();msg.From = new MailAddress("Raj_84@hotmail.com", "Raj");msg.To.Add(new MailAddress("neerajb@nfstechgroup.com", "Neeraj")); msg.Subject = "Send Calendar Appointment Email with Attachment"; msg.Body = "Here is the Body Content";StringBuilder str = new StringBuilder(); str.AppendLine("BEGIN:VCALENDAR"); str.AppendLine("PRODID:-//Workspace");  str.AppendLine("VERSION:2.0");      str.AppendLine("METHOD:REQUEST"); str.AppendLine("X-MS-OLK-FORCEINSPECTOROPEN:TRUE"); str.AppendLine("BEGIN:VTIMEZONE");str.AppendLine("TZID:GMT Standard Time");str.AppendLine("BEGIN:STANDARD");str.AppendLine("DTSTART:20171029T020000");str.AppendLine("RRULE:FREQ=YEARLY;BYDAY=5SU;BYMONTH=10");str.AppendLine("TZOFFSETFROM:+0100");str.AppendLine("TZOFFSETTO:+0000");str.AppendLine("END:STANDARD");str.AppendLine("BEGIN:DAYLIGHT");str.AppendLine("DTSTART:20170326T010000");str.AppendLine("TZOFFSETFROM:+0000"); str.AppendLine("TZOFFSETTO:+0100");  str.AppendLine("RRULE:FREQ=YEARLY;BYDAY=4SU;BYMONTH=3");str.AppendLine("END:DAYLIGHT");str.AppendLine("END:VTIMEZONE");str.AppendLine("BEGIN:VEVENT");str.AppendLine("DTSTART;TZID=\"GMT Standard Time\":20171222T144500\"");

                    str.AppendLine("DTSTAMP:20171222T141905Z");

                    str.AppendLine("DTEND;TZID=\"GMT Standard Time\":20171222T154500\"");

                    str.AppendLine("LOCATION:4-402 (Max 4)");

                    str.AppendLine("CATEGORIES:VcalWorkspace");

                    str.AppendLine("SEQUENCE:4");

                    str.AppendLine("UID:a1b32017-f0ac-4093-a74f-2b9a3a366424");

                    str.AppendLine("DESCRIPTION:Meeting invitation:\n");

                    str.AppendLine("X-ALT-DESC;FMTTYPE=text/html:Meeting invitation:<br/>");

                    str.AppendLine("SUMMARY:RR-01-Neeraj");

                    str.AppendLine("ORGANIZER:MAILTO:georgeg@nfstechgroup.com");

                    str.AppendLine("ATTENDEE;CN=\"neerajb@nfstechgroup.com\";RSVP=TRUE:mailto:neerajb@nfstechgroup.com");str.AppendLine("BEGIN:VALARM");str.AppendLine("TRIGGER:-PT15M");str.AppendLine("ACTION:DISPLAY");str.AppendLine("DESCRIPTION:Reminder");str.AppendLine("END:VALARM");str.AppendLine("END:VEVENT");str.AppendLine("END:VCALENDAR");System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");ct.Parameters.Add("method", "REQUEST");var typeHTML = new System.Net.Mime.ContentType("text/html");var htmlViewAttach = AlternateView.CreateAlternateViewFromString("<br/>", typeHTML);var resc = new LinkedResource(@"C:\Users\Admin\Desktop\NFS Holidays for Pune 2018.pdf");resc.TransferEncoding = TransferEncoding.Base64;resc.ContentId = "NFS Holidays for Pune 2018.pdf";resc.ContentType =ewystem.Net.Mime.ContentType(MediaTypeNames.Application.Pdf);htmlViewAttach.LinkedResources.Add(resc);msg.AlternateViews.Add(htmlViewAttach); AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct); msg.AlternateViews.Add(avCal);sc.Send(msg);

    It sends vacal with attachment but shows attachment name Att0001.pdf 

    

    What should do to show correct name of file


    Neeraj

    Friday, December 22, 2017 3:31 PM
  • Kindly help asap

    Neeraj

    Sunday, December 24, 2017 10:47 PM