无法通过MailKit发送带有图片附件的iCal.net

时间:2019-07-23 15:46:36

标签: icalendar mailkit

我正在尝试发送通过iCal.net生成的.ics文件。在Outlook中打开文件很好,并且具有我尝试通过MailKit发送的图像附件,但是在通过Mailkit发送时,图像不存在。

BEGIN:VCALENDAR 方法:要求 PRODID:-// github.com/rianjs/ical.net//NONSGML ical.net 4.0 // EN 版本:2.0 开始:温柔 ATTACH; FMTTYPE = image / png; X-FILENAME = qrcode.png; VALUE = BINARY; ENCODING = BASE6  4:iVBORw0KGgoAAAANSUhEUgAABkAAAAZAAAAQMAAAAbwhzkAAAABGdBTUEAALGPC / xhBQAAAAF  zUkdCAK7OHOkAAAAGUExURQAAAP7 + / soH9D0AAAYwSURBVHja7dyxcYNAEAVQPA4UugRKoTRc  GqW4BIcKNMKBcABzXu8JhIXn / UwSJ / Zt / Oea8Z + kAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA  QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ  EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE  BAQEBAXkiyGdTn77iaHt79nLHa1oQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ  EBAQEBAQEBAQEJA9IC + ZVvolhHS3b88hpE + 130FAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ  EBAQEBAQEBAQEBAQEBAQEBAQP4AMmQK7vNpruVme80OppxAQEBAQEBAQEBAQEBAQEBAQEBAQE  BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECOCeluH1PdeBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA  QEBAQEBAQEBAQEBAQEBAQEBAQEBAQkGND4pvaQUBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA  QEBAQEBAQEBAQEBAQEBAQEBADgYJE0OG + TTh0TggICAgICAgICAgICAgICAgICAgICAgICAgI  CAgICAgICAgICAgICAgICAgICB7QqqSgpS78TUBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ  EBAQEBAQEBAQEBAQEBAQEBAQF5LGRF4h2MjwoICAgICAgICAgICAgICAgICAgICAgICAgICAg  ICAgICAgICAgICAgICAgICMhGkPI0izvTP6Ju / IosLnk / b1 / yBwEBAQEBAQEBAQEBAQEBAQEB  AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB + RVyz1 + mdjDlEu6gW4wKAgICAgICAgICAgICA  gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyB6Scc1hp76MdjCGk3I0f5jsAAQEBAQ  EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQHZBRJ348PhYkhNrb6rWTI  ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMi2kB8yPfTRJFKe  pnz07fbjdX40tT4QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE  JCtICuSqtWndjDllHotCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA  gICAjIRpDPpj797B + umSOv08PvGcj0sQUBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE  BAQEBAQEBAQEBAQEBAdkD8pJppV / mkMXRYT5VuRtf3kFXU8kHAQEBAQEBAQEBAQEBAQEBAQEB  AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQF5DGQoltbbImQxzYpMkMVN7SAgICAgICAgICAgI  CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDegMZype8p46CgICAgICAgICAgI  CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA8AeSem9pr0oKAgICAgICAgICgIC  AgICAgICAgICAgICAgICAgICAgICAgICAgICAgOwJSU0zh3ynW7yvOM17ceRurAgICAgI  CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgMi2kKr00dFTZgdTrjU7A  AEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB2RhyvICAgICAgI  CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgICg  AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg  gICAgICAgICAgICAgICAgICAgICAgICAgICArMkXJlylJdANIpEAAAAASUVORK5CYILyxAyAPDEDI  E / MAMgTMwDyxAyAPDEDIE / MAMgTMwDyxAyAPDEDIE / MAMgTMwDyxAyAvDnnbM / wVjPz8rNbZ /  VpM98ofs / F97vFWfF33MwAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA  8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIC8Z2vhmdlaesXNfs85K + veKM7sm / zdir + F  G1v / OVvczADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIE  zMA8sQMgDwxAyBPzADIEzMA8sQMgLw552zPwC80Myvrbn3PN / st / gbt9 + tu9vtp695wMwMgT8  wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA  8MQMgT8wAyBMzAPKerYVnZmtpvuics / Lsp30bW / u9eUdbbs5qa7 / FmYvczADIEzMA8sQMgDwx  AyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8  sQMgLxne4BXnHO2R8iYGev + cDff881 + P + 2stpj5PdzMAMgTMwDyxAyAPDEDIE / MAMgTMwDyxA  yAPDEDIE / MAMgTMwDyxAyAPDEDIE / MAMgTMwDyxAyAPDEDIE / MAMgTMwDyxAyAvGd7gHebme0  Rvu2csz3Ct93MfPOOimdV / CZv2O / XbX3PxZndzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwx  AyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgLxnewD4q3POy8 / Oz  Mq6vMfWt7Fla + bib8HNDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyB  MzAPLEDIA8MQMgT8wAyBMzAPLEDIA8MQMgT8wAyHu2B + B3mpntEb7tZuZzzsqzN4rv6MbNOW9  9GzduZi7u180MgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQM  gDwxAyBPzADIEzMA8sQMgDwxAyBPzADIe7YHeLdzzvYI / EHF9zszLz9b3O + Wm3Mu + rRvw80Mg  DwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEzMA8sQMgDwxAyBPzADIEz  MA8sQMgDwxAyBPzADIe7YHeMXMbI / AH3TOWVn3076rm3O + OaviujfM / B5uZgDkiRkAeWIGQJ6  YAZANZgDkiRkAeWIGQJ6YAZAnZgDkiRkAeWIGQJ6YAZAnZgDkiRkAeWIGQJ6YAZAnZgDkiRkA  eWIGQN6cc7ZnAIArbmYA5IkZAHliBkCemAGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAHliBkCem  AGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAH  liBkCemAGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAHliBkCemAGQJ2YA5IkZAHliBkDe / wB5w4S  q9G4M2AAAAABJRU5ErkJggg == 参与者; CN = Wayne Lee; PARTSTAT = REQ-PARTICIPANT; RSVP = TRUE:mailto:song.John @  company.com 类别:公共 描述:您好\,\ n \ n我们希望您喜欢我们的访问 DTEND:20190723T183343 DTSTAMP:20190723T153343Z DTSTART:20190723T173343 GEO:52.051681; -4.283453 位置:法国ORGANIZER; CN = Wayne Lee:mailto:wayne@digital-forge.co.uk 序列:0 摘要:面试 透明:透明 UID:b9fb0c3e-728c-4121-912e-9412885ebbb4 开始:VALARM 动作:显示 摘要:在1小时前提醒 触发器:-PT1H 结束:VALARM 结束:香气 END:VCALENDAR

然后尝试发送以下代码:

       var ical = new TextPart("calendar")
        {
            ContentTransferEncoding = ContentEncoding.Default,
            ContentDisposition = new ContentDisposition (ContentDisposition.Inline),
            Text = calendar
        };

        ical.ContentType.Parameters.Add("method", "REQUEST");
        message.Body = ical;    

任何帮助将不胜感激。

谢谢

我可以很好地接受/拒绝日历邀请,但是通过电子邮件,附件不会显示。

1 个答案:

答案 0 :(得分:0)

根据我从Outlook发送给我的示例会议请求,Outlook不会在 NodeList neighbors = priceFactorNode.getChildNodes(); Node unwantedNode = neighbors.item(1); NodeList children = unwantedNode.getChildNodes(); priceFactorNode.removeChild(unwantedNode); for(int x = 0; x < children.getLength(); x++) { priceFactorNode.appendChild(children.item(x)); } 部分中添加Content-Disposition

它也以base64编码。

尝试一下:

text/calendar

我还注意到Outlook倾向于使用以下结构构造MIME消息(可能需要也可能不需要):

var ical = new TextPart("calendar")
{
    ContentTransferEncoding = ContentEncoding.Base64,
    Text = calendar
};

ical.ContentType.Parameters.Add("method", "REQUEST");