开发者

Reading outlook appointment replies with PHP

开发者 https://www.devze.com 2023-03-13 08:37 出处:网络
I have a page where the admins create events for a committee and the calendar notification is sent out to all of the member of the given committee.

I have a page where the admins create events for a committee and the calendar notification is sent out to all of the member of the given committee.

What I want to be able to do is somehow retrieve the reply, whether it was accepted, tentative, or declined, and display the list of respon开发者_开发百科ses along with the event info.

The event creator will be setup to use an email address with the sole purpose of creating the events.

I am able to connect to the inbox and read emails, i can read the initial event creation just fine, like its an ics file, but when i try to read the response from someone all i get is garbage:

--_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLg0KDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: base64 PGh0bWw+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0i dGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29udGVu dD0iTWljcm9zb2Z0IEV4Y2hhbmdlIFNlcnZlciI+DQo8IS0tIGNvbnZlcnRlZCBmcm9tIHJ0ZiAt LT4NCjxzdHlsZT48IS0tIC5FbWFpbFF1b3RlIHsgbWFyZ2luLWxlZnQ6IDFwdDsgcGFkZGluZy1s ZWZ0OiA0cHQ7IGJvcmRlci1sZWZ0OiAjODAwMDAwIDJweCBzb2xpZDsgfSAtLT48L3N0eWxlPg0K PC9oZWFkPg0KPGJvZHk+DQo8Zm9udCBmYWNlPSJDYWxpYnJpLCBzYW5zLXNlcmlmIiBzaXplPSIy Ij4NCjxkaXY+SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLjwvZGl2Pg0K PGRpdj4mbmJzcDs8L2Rpdj4NCjwvZm9udD4NCjwvYm9keT4NCjwvaHRtbD4NCg== --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/calendar; charset="utf-8"; method=REPLY Content-Transfer-Encoding: base64 QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVQTFkNClBST0RJRDpNaWNyb3NvZnQgRXhjaGFuZ2Ug U2VydmVyIDIwMDcNClZFUlNJT046Mi4wDQpCRUdJTjpWVElNRVpPTkUNClRaSUQ6Q2VudHJhbCBT dGFuZGFyZCBUaW1lDQpCRUdJTjpTVEFOREFSRA0KRFRTVEFSVDoxNjAxMDEwMVQwMjAwMDANClRa T0ZGU0VURlJPTTotMDUwMA0KVFpPRkZTRVRUTzotMDYwMA0KUlJVTEU6RlJFUT1ZRUFSTFk7SU5U RVJWQUw9MTtCWURBWT0xU1U7QllNT05USD0xMQ0KRU5EOlNUQU5EQVJEDQpCRUdJTjpEQVlMSUdI VA0KRFRTVEFSVDoxNjAxMDEwMVQwMjAwMDANClRaT0ZGU0VURlJPTTotMDYwMA0KVFpPRkZTRVRU TzotMDUwMA0KUlJVTEU6RlJFUT1ZRUFSTFk7SU5URVJWQUw9MTtCWURBWT0yU1U7QllNT05USD0z DQpFTkQ6REFZTElHSFQNCkVORDpWVElNRVpPTkUNCkJFR0lOOlZFVkVOVA0KT1JHQU5JWkVSO0NO PVJ5YW4gTGVpc2luZzpNQUlMVE86cmxlaXNpbmdAbWl0Y2hlbGx3YXluZS5jb20NCkFUVEVOREVF O1BBUlRTVEFUPUFDQ0VQVEVEO0NOPUtlbGxpIEdldHRpbmdlcjpNQUlMVE86a2VsbGlAbWl0Y2hl bGx3YXluZS5jbw0KIG0NCkNPTU1FTlQ7TEFOR1VBR0U9ZW4tVVM6SnVzdCBpbiBjYXNlIHlvdSBu ZWVkIHRvIHNlZSBhIHJlc3BvbnNlLlxuXG4NClNVTU1BUlk7TEFOR1VBR0U9ZW4tVVM6QWNjZXB0 ZWQ6IHRlc3RpbmcNCkRUU1RBUlQ7VFpJRD1DZW50cmFsIFN0YW5kYXJkIFRpbWU6MjAxMTA2MTVU MTUzMDAwDQpEVEVORDtUWklEPUNlbnRyYWwgU3RhbmRhcmQgVGltZToyMDExMDYxNVQxNjAwMDAN ClVJRDowNDAwMDAwMDgyMDBFMDAwNzRDNUI3MTAxQTgyRTAwODAwMDAwMDAwMjBFNkFFN0Y2RDJC Q0MwMTAwMDAwMDAwMDAwMDAwMA0KIDAxMDAwMDAwMDBCRDdCRDdDNDlDMjIyNDg4QTZFMTE3OTc4 QzdDNUQyDQpDTEFTUzpQVUJMSUMNClBSSU9SSVRZOjUNCkRUU1RBTVA6MjAxMTA2MTVUMjAwNDM3 Wg0KVFJBTlNQOk9QQVFVRQ0KU1RBVFVTOkNPTkZJUk1FRA0KU0VRVUVOQ0U6MA0KTE9DQVRJT047 TEFOR1VBR0U9ZW4tVVM6TVdUDQpYLU1JQ1JPU09GVC1DRE8tQVBQVC1TRVFVRU5DRTowDQpYLU1J Q1JPU09GVC1DRE8tT1dORVJBUFBUSUQ6LTExOTAxNzI3MDkNClgtTUlDUk9TT0ZULUNETy1CVVNZ U1RBVFVTOkJVU1kNClgtTUlDUk9TT0ZULUNETy1JTlRFTkRFRFNUQVRVUzpCVVNZDQpYLU1JQ1JP U09GVC1DRE8tQUxMREFZRVZFTlQ6RkFMU0UNClgtTUlDUk9TT0ZULUNETy1JTVBPUlRBTkNFOjEN ClgtTUlDUk9TT0ZULUNETy1JTlNUVFlQRTowDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFSDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_--

Below is how I am creating and sending the notifications.

$vcal = "BEGIN:VCALENDAR\r\n";
$vcal .= "PRODID:-//CompanyName//ProductName//EN\r\n";
$vcal .= "VERSION:2.0\r\n";
$vcal .= "METHOD:REQUEST\r\n";
$vcal .= "BEGIN:VEVENT\r\n";
foreach($comstmt->fetchAll(PDO::FETCH_ASSOC) as $commem){
    $vcal .= "ATTENDEE;CN=\"".$commem['first']." ".$commem['last']."\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:".$commem['email']."\r\n";
}
$vcal .= "ATTENDEE;CN=\"Ryan Leising\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:rleising@mitchellwayne.com\r\n";
$vcal .= "DESCRIPTION:".$_POST['event_description']."\r\n";
$vcal .= "DTEND:$dtend\r\n"; 
$vcal .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
$vcal .= "DTSTART:$dtstart\r\n";
$vcal .= "LOCATION:".$_POST['event_location']."\r\n";
$vcal .= "SUMMARY:".$comname." event\r\n";
$vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-domain.com\r\n";
$vcal .= "BEGIN:VALARM\r\n";
$vcal .= "TRIGGER:-PT15M\r\n";
$vcal .= "ACTION:DISPLAY\r\n";
$vcal .= "END:VALARM\r\n";
$vcal .= "END:VEVENT\r\n";
$vcal .= "END:VCALENDAR\r\n";
$headers = "From: rleising@mitchellwayne.com\r\nReply-To: rleising@mitchellwayne.com"; 
$headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; method=REQUEST; charset=\"iso-8859-1\"";
$headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 
$mailsent = mail($to, $comname." event", $vcal, $headers);


Start with PHP IMAP to check the box for new messages and sort out the ones you want to parse. Beyond that, you'll need to identify the structure of the Outlook reply messages, and start parsing out the information you want. preg_match() will be your friend to extract text there, but without seeing examples of the messages we won't be able to help too much more.

The mailparse library will help to deconstruct the MIME messages, if simply retrieving the message body if imap_fetchbody() isn't enough.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号