2

Outlook でこれらの ics ファイルを開いて予定を保存できるように、ユーザーに icalendar を送信しようとしています。私が使用しているメーラーは「phpmailer.php」です。

問題は、メッセージ本文で ical 形式を html として送信することです。これが私のコードです


$text="
BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
CATEGORIES:MEETING
STATUS:TENTATIVE
DTSTART:".$startDateTime."
DTEND:".$endDateTime."
SUMMARY:Interview for the candidate".$cname."
DESCRIPTION:".$message."
CLASS:PRIVATE
END:VEVENT
END:VCALENDAR";

$mail->SetFrom('xxxxxx@yahoo.com', 'xxxx');
$mail->IsSMTP();
$mail->Host = "smtp.mail.yahoo.com";

$mail->SMTPAuth = true;
$mail->Username = 'xxxxxxxx@yahoo.com';
$mail->Password = 'xxxxx';


$mail->AddAddress($addresses[$i]);
$mail->Subject    = "Interview schedule of Candidate";

    $headers = "From: Sender\n";
        $headers .= "Reply-To: xxxxxx@yahoo.com\n";
        $headers .= "MIME-Version: 1.0\n";
        $headers .= "Content-Type: text/calendar; method=REQUEST; charset=utf-8\n";
        $headers .= "Content-Transfer-Encoding: 8bit\n";
        $headers .= "Content-class: urn:content-classes:calendarmessage\n";
$mail->Body=$body;

if(!$mail->Send($headers,$body)) 
{
        echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
    echo "Message sent!";
}


私のコードの何が問題なのか教えてください。前もって感謝します

4

3 に答える 3

5

次の解決策は私のために働いた:

$mail->Subject = $name;
$mail->Body = $description; 
$mail->AltBody = $body; // in your case once more the $text string
$mail->Ical = $message; // ical format, in your case $text string
于 2013-11-01T14:51:23.153 に答える
2

あなたも試すことができました:

$mail->IsHTML(FALSE);
于 2012-10-25T16:39:40.197 に答える
1

このソリューションは私にとってはうまくいきます。アタッチメントなし

$mail->AddStringAttachment("my_content_here", "meeting.ics", "7bit", "text/calendar; charset=utf-8; method=REQUEST");
于 2015-09-14T06:35:38.967 に答える