多次努力后,使用phmailer发送内联会议邀请失败

its been three days now, i spend lot of time and efforts on stackoverflow to figure it out, finally thought of posting this question, with the below code i can send email invite but in attachment form, i want inline attachment

i am able to send invite with attached .ical file with below code, but i dont want attachment, i want inline invite along with mail body,

$headers = 'Content-Type:text/calendar; Content-Disposition: inline;
    charset=utf-8;
';
$headers .= "Content-Type: /text/plain;charset=\"utf-8\"
"; 

$attachment="
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Asia/Kolkata
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "example.com
DTEND:". $dbInsertEndTime . "T" . $EndTime . "00
DTSTAMP:" . gmdate('Ymd') . 'T' . gmdate('His') . "Z
DTSTART:". $dbInsertStartDate . "T" . $StartTime . "00
SUMMARY:" . $subject . "
ORGANIZER;CN=Foobar:mailto:foobar@myemail.com
LOCATION:" . $Location . "
DESCRIPTION:" . $desc . "
TRANSP:TRANSPARENT
BEGIN:VALARM
TRIGGER:-PT30M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR";

$headers .= $attachment;


$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->SMTPDebug = 0;  
$mail->Host = 'xxxxxxxxxx';
$mail->Port = 25;                                    // TCP port to connect to
$mail->Username = EMAIL;                 // SMTP username
$mail->Password = PASS;           
$mail->setFrom(EMAIL, 'xxxx');
$ext = "@outlook.com";
$mail->addAddress($my_ID.$ext);     // Add a recipient
$mail->addReplyTo(EMAIL);
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = ($subject);
$mail->addStringAttachment($attachment,'invite.ics','base64','text/calendar');


$mail->Body    = "<html>
<head>
<title>Meeeting Invite</title>
<style type='text/css'>
table.example2 {background-color:transparent;border-collapse:collapse;width:100%;}
table.example2 th, table.example2 td {text-align:center;border:1px solid black;padding:5px;}
table.example2 th {background-color:AntiqueWhite;}
table.example2 td:first-child {width:15%;}
</style>
</head>
<body>
<p>Dear ". $Employee_Name. " ,<br /><br /></p>
<p>Your meeting  Scheduled.<br /></p>
</body>
</html>
";
dter8514
dter8514 能够让它工作,但附件为.ics文件,我想要内联附件
12 个月之前 回复

1个回答

Why not use PHPMailer’s built-in iCal support?

$mail->Ical = $attachment;

All that messing with headers you’re doing is counter-productive - let PHPMailer deal with it for you.

Bear in mind that iCal support in email clients is very inconsistent, so don’t expect it to work the same way on different systems.

douquan1953
douquan1953 我们没有什么可以继续 - 发布修改后的代码。
12 个月之前 回复
dongsheng9203
dongsheng9203 没有运气,有人可以提出解决方案吗?
12 个月之前 回复
dongyihang3575
dongyihang3575 您尚未发布修改后的代码或调试输出,因此我无法再告诉您更多信息。
12 个月之前 回复
dtv55860
dtv55860 我试过这个,但再没有什么期望邮件正文内容
12 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问