WP_Mail ICS Outlook Meeting Invite
-
Good Evening,
I hope that someone can help me.
What I would like to achieve is to send an ics or Outlook Meeting invite through an email.
So here is some of my code (i only copy relevant parts because i use a class that manages mailer, the same class sends normal email perfectly):
$date = "20170515"; $startTime = "1300"; $endTime = "1400"; $subject = "Meeting"; $desc = "Details"; $SendMail_To = '[email protected]'; $SendMail_Subject = 'TESTING'; $SendMail_Message = " BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VEVENT UID:" . md5(uniqid(mt_rand(), true)) . "example.com DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z DTSTART:".$date."T".$startTime."00Z DTEND:".$date."T".$endTime."00Z SUMMARY:".$subject." DESCRIPTION:".$desc." END:VEVENT END:VCALENDAR ";
Then in my mailer class I change the following:
function set_html_content_type() { //return 'text/html'; return 'text/calendar'; } add_filter ('wp_mail_content_type', 'set_html_content_type' ); wp_mail($SendMail_To,$SendMail_Subject,$SendMail_Message,$Headers,$Attachment_Array); remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
I receive the email fine, and there is a Calendar Item attached, but when I want to open the attachment, it tells me that it cannot open the file.
Can you please help?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WP_Mail ICS Outlook Meeting Invite’ is closed to new replies.