ical-org/ical.net

ios 16 calendar issue

Closed this issue · 0 comments

Greetings to everyone;

I am new here. In one part of the application, I send appointment information to my customers via email. Before iOS 16 everything was working fine. However, at the moment, we cannot see the appointment information in the Mail (iphone) application. My html codes in the mail are working, but I cannot register/update the appointment. How can I fix this?

private string SendEmail(JTermin termin, List<MailAddress> ToMail, char notificationType, string name)
{
            string result = string.Empty;
            var smtpClient = new SmtpClient(configuration.GetSection("MailSettings").GetSection("SmtpServer").Value)
            {
                Port = Convert.ToInt32(configuration.GetSection("MailSettings").GetSection("Port").Value),
                Credentials = new NetworkCredential(configuration.GetSection("MailSettings").GetSection("MailAccount").Value, configuration.GetSection("MailSettings").GetSection("Password").Value),
                EnableSsl = Convert.ToBoolean(configuration.GetSection("MailSettings").GetSection("EnableSSL").Value)
            };
            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = true;
            msg.From = new MailAddress(configuration.GetSection("MailSettings").GetSection("From").Value);
            foreach (var item in ToMail)
            {
                msg.To.Add(item);
            }
            msg.Subject = termin.Title;
            if (notificationType == 'd')
            {
                msg.Body = termin.extendedProps.Message += " DIESER TERMIN WIRD IN 5 MINUTEN GELÖSCHT!";
            }
            else
            {
                msg.Body = termin.extendedProps.Message;
            }
            Calendar iCal = new Calendar();
            if (notificationType == 'c')
                iCal.Method = "REQUEST";
            else
                iCal.Method = "CANCEL";
            CalendarEvent evt = iCal.Create<CalendarEvent>();
            evt.Summary = termin.Title;
            evt.Start = new CalDateTime(termin.Start);
            evt.End = new CalDateTime(termin.End);
            evt.Description = termin.extendedProps.Message;
            evt.Location = termin.extendedProps.Location;
            evt.Uid = termin.Id;
            evt.Sequence = termin.Sequence;
            CalendarSerializer serializer = new CalendarSerializer(iCal);
            string icalData = serializer.SerializeToString();
            System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
            System.Net.Mime.ContentType ct2 = new System.Net.Mime.ContentType("text/html");
            if (notificationType == 'c')
                ct.Parameters.Add("method", "REQUEST");
            else
                ct.Parameters.Add("method", "CANCEL");
            string Signature = configuration.GetSection("FolderAddresses").GetSection("SignatureFolder").Value+name+".jpg";
            **AlternateView avCal = AlternateView.CreateAlternateViewFromString(icalData, ct);**
            AlternateView avCal2 = AlternateView.CreateAlternateViewFromString(termin.extendedProps.Message + $"<html><body><hr/><img src=\"{Signature}\"></img></body></html>", ct2);
            msg.AlternateViews.Add(avCal);
            msg.AlternateViews.Add(avCal2);
            try
            {
                smtpClient.Send(msg);
                result = "success";
            }
            catch (Exception error)
            {
                result = error.Message;
            }
            return result;
        }