i've looked @ lot of other questions on stackoverflow this, i'm still confused.
i want download attachments of emails- able this, if email had 1 attachment; when email has more 1 attachment, stops working.
how download multiple attachments per email?
also, there way determine file extension when downloading? currently, example, if there pdf attachment, file downloads, no .pdf, windows doesn't know file type.
the code below here: mailkit save attachments. i've been basing code off of that.
foreach (var attachment in message.attachments) { using (var stream = file.create ("filename")) { if (attachment messagepart) { var part = (messagepart) attachment; part.message.writeto (stream); } else { var part = (mimepart) attachment; part.contentobject.decodeto (stream); } } }
please help! thanks!
the code pasted save attachments.
look @ raw message source. each "attachment" consider attachment have header content-disposition: attachment
? if not, that's problem hitting.
you can instead use message.bodyparts
, apply own logic determine if part consider "attachment".
also, there way determine file extension when downloading? currently, example, if there pdf attachment, file downloads, no .pdf, windows doesn't know file type.
yes. can check file extension on filename
property on mimepart
objects.