c# - Outlook issue with sending iCalendar meeting invitation with additional (not .ics) attachment -
i need send meeting invitations can include .pdf attachments. i'm building system.net.mail.mailmessage alternative view (for icalendar content), body , attachment if exists. need popular mail clients (that support calendars) able deal invitation emails.
here code pretty working for:
gmail (web/mobile app) with/without pdf attachment
yahoo mail (web/mobile app) with/without pdf attachment
outlook (desktop) without pdf attachment only
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; } so issue when email attachment being opened in outlook.
here how such email opened in outlook without pdf attachment - ok:
here how such email opened in outlook with pdf attachment - ok: there no issue icalendar (ics) content system.net.mail.mailmessage object.
so problem need outlook open email attachment meeting invitation not ordinary email.
any suggestions can wrong mailmessage parts? in advance.
there quite few similar questions. need make sure mime structure of message right.
see example outlook 2013 invite not showing embeded attachment - text/calendar;method=request
Comments
Post a Comment