首页 > 解决方案 > 如何在 magento 2.x 中使用 TransportBuilder 发送 iCal 会议请求

问题描述

我想将iCal会议请求与邮件集成(在 中magento 2.2.4 v)。我正在尝试以下方式,但它不起作用。请帮忙。

.bin它在带有文件的邮件中显示为附件

TransportBuilder.php

namespace Vendor\module\Magento\Mail\Template;

class TransportBuilder extends \Magento\Framework\Mail\Template\TransportBuilder
{  


    const TYPE_TEXTCALENDER="text/calendar";

    public function addAttachment(
       $body,
       $filename    = null,
       $mimeType    = self::TYPE_TEXTCALENDER,
       $disposition = \Zend_Mime::DISPOSITION_ATTACHMENT,
       $encoding    = \Zend_Mime::ENCODING_BASE64
       ) {
         $this->message->createAttachment($body, $mimeType, $disposition, 
          $encoding, $filename);
           return $this;
      }
}

发送邮件代码:-

.............
 $transport = $this->_transportBuilder- 
 >setTemplateIdentifier('template_identifier')
                        ->setTemplateOptions($templateOptions)
                        ->setTemplateVars($templateVars)
                        ->setFrom($from)
                        ->addTo($to)
                        ->addAttachment($ical)
                        ->getTransport();
        $transport->sendMessage();

请检查下面使用的示例 ical 文件的链接:- https://gist.github.com/DeMarko/6142417

标签: phpemailmagento2icalendar

解决方案


推荐阅读