I am working on a script that includes access to the mail server, receiving email, analyzing information from email, creating an event (ics file) from the analyzed information, and then sending an invitation to the event along with the original letter as DESCRIPTION ics file. I am doing all of the above in php. I was stuck in the last step, i.e. sent the original email body (html) as a DESCRIPTION.
I realized that the ics file field DESCRIPTION does not suit line breaks (I must use \ n to send multi-line descriptions). So after extracting the body of the email, I delete all the "\ r \ n" and I get the html code in the line without line breaks.
The study found that Outlook uses something like X-ALT-DESC.So to analyze html in the ics file, I save both DESCRIPTION and X-ALT-DESC as a line with html code. But sending email causes Outlook to ignore most of the html, and end the tags on it at the end, and I get only part of the original message.
To find the problem, I sent the same mail to gmail and then downloaded the ics file. While checking, I noticed that gmail does not change DESC in any way, but some line breaks are added automatically. And I noticed that outlook ignores html after the first line break and adds its own tags to complete the html along with native Microsoft Exchange stuff at the beginning.
I have no clue if the problem is in php (to add line breaks) or if there is a restriction on the ics file regarding the length of the html code (i.e. after the line number with automatic line break is added to X-ALT-DESC or something else). Thank you for any help, and I want to disclose that I had no experience in php before starting with this script.
CODE FOR EXTRACTION OF THE MESSAGE (HTML) AND CONFIGURING THIS IN A LINE WITHOUT CHECKING:
$infoxo = quoted_printable_decode(imap_fetchbody($imap,$email_id,"1")); emailyy = str_replace(array("\r\n"),"\n",$infoxo); $lines = explode("\n",$emailyy); $new_lines =array(); foreach($lines as $i => $line) { if(!empty($line)) $new_lines[]=trim($line); $emailzz = implode($new_lines); } $desc = $emailzz;
IN OTHER FUNCTIONS (CODE FOR ICS FILE):
$headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;\r\n'; $headers .= "Content-Type: /text/plain;charset=\"utf-8\"\r\n"; $message = "BEGIN:VCALENDAR VERSION:2.0 PRODID:-//BLAH/BLAH METHOD:REQUEST BEGIN:VEVENT UID:" . md5(uniqid(mt_rand(), true)) . "example.com DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z DTSTART:".$start1."00Z DTEND:".$end1."00Z DESCRIPTION:".$desc." SUMMARY:".$subject." ORGANIZER;CN=".$organizer.":mailto:".$organizer_email." LOCATION:".$location." X-ALT-DESC;FMTTYPE=text/html:".$desc." ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS- ACTION;RSVP=TRUE;CN".$participant_name_1.";X-NUM-GUESTS=0:MAILTO:".$participant_email_1." END:VEVENT END:VCALENDAR"; $headers .= $message;
Then I use phpamiler () to send email