【问题标题】:Outlook issue with sending iCalendar meeting invitation with additional (not .ics) attachment发送带有附加(非 .ics)附件的 iCalendar 会议邀请的 Outlook 问题
【发布时间】:2015-10-06 09:36:03
【问题描述】:

我需要发送有时可能包含 .pdf 附件的会议邀请。 所以我正在使用替代视图(用于 iCalendar 内容)、正文和附件(如果存在)构建 System.Net.Mail.MailMessage。我需要最流行的邮件客户端(支持日历)能够处理我的邀请电子邮件。

这是我非常适合的代码:

gmail(网络/移动应用程序)带/不带 pdf 附件
带有/不带有 pdf 附件的雅虎邮件(网络/移动应用程序)
仅没有pdf附件的outlook(桌面)

    public virtual MailMessage CreateMailMessage(string content, Meeting meeting)
    {
        MailMessage mailMessage = new MailMessage();
        mailMessage.From = _mailsAddressesProvider.GetFromEmaiMailAddress(meeting);
        mailMessage.To.AddRange(_mailsAddressesProvider.GetToEmaiMailAddresses(meeting));
        mailMessage.CC.AddRange(_mailsAddressesProvider.GetCCEmailAddresses(meeting));
        mailMessage.Bcc.AddRange(_mailsAddressesProvider.GetBCCEmailAddresses(meeting));

        mailMessage.Subject = GetMessageSubject(meeting);
        mailMessage.Body = GetMessageBody(meeting);
        mailMessage.IsBodyHtml = IsBodyHtml();

        ContentType contentType = new ContentType("text/calendar");
        contentType.Parameters.Add("method", Method);
        contentType.Parameters.Add("name", AttachmentName);
        AlternateView avCal = AlternateView.CreateAlternateViewFromString(content, contentType);
        mailMessage.AlternateViews.Add(avCal);

        AddAttachments(mailMessage, meeting);

        return mailMessage;
    }

    public virtual bool AddAttachments(MailMessage mailMessage, Meeting meeting)
    {
        byte[] meetingMaterialsBytes = _meetingMaterialsRepository.GetMeetingMaterails(meeting);
        if (meetingMaterialsBytes == null || meetingMaterialsBytes.Length == 0)
        {
            return false;
        }
        ContentType contentType = new ContentType(MediaTypeNames.Application.Pdf);
        Attachment attach = new Attachment(new MemoryStream(meetingMaterialsBytes), contentType);
        attach.ContentDisposition.FileName = "MeetingMaterials.pdf";
        attach.ContentDisposition.Inline = true;
        attach.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
        attach.ContentId = "MeetingMaterials";

        mailMessage.Attachments.Add(attach);
        return true;
    }

所以问题是在 Outlook 中打开带有附件的电子邮件时。

以下是在 Outlook 中打开此类电子邮件的方式没有 pdf 附件 - 好的:

以下是在 Outlook 中打开此类电子邮件的方式带有 pdf 附件 - 好的: iCalendar (ics) 内容可能没有问题,但 System.Net.Mail.MailMessage 对象可能没有问题。

所以问题是我需要 Outlook 打开带有附件的电子邮件作为会议邀请,而不是普通电子邮件。

关于我的 MailMessage 部分可能有什么问题有什么建议吗? 提前致谢。

【问题讨论】:

    标签: c# email outlook icalendar mailmessage


    【解决方案1】:

    有很多类似的问题。您需要确保邮件的 MIME 结构正确。

    例如见Outlook 2013 invite not showing embeded attachment - text/calendar;method=REQUEST

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 2015-04-14
      • 2020-11-18
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多