barkome
asked on
S22.Imap dll save attached files to designated directory
Hello
Im S22.Imap dll with the following C# code below to save attached files to emails within a mailbox.
Does anyone know I can save the attached files to a directory?
Source of the code is : https://github.com/smiley2 2/S22.Imap /blob/mast er/Example s.md#7
Im S22.Imap dll with the following C# code below to save attached files to emails within a mailbox.
Does anyone know I can save the attached files to a directory?
Source of the code is : https://github.com/smiley2
namespace S22
{
class Program
{
static void Main(string[] args)
{
using (ImapClient Client = new ImapClient("server", port, @"domain\user_id\mailbox", "Password", AuthMethod.Login, false))
{
// This returns all messages sent since August 23rd 2016.
IEnumerable<uint> uids = Client.Search(SearchCondition.SentSince(new DateTime(2016, 8, 26)));
// The expression will be evaluated for every MIME part
// of every mail message in the uids collection.
IEnumerable<MailMessage> messages = Client.GetMessages(uids,
(Bodypart part) =>
{
// We're only interested in attachments.
if (part.Disposition.Type == ContentDispositionType.Attachment)
{
Int64 TwoMegabytes = (1024 * 1024 * 2);
if (part.Size > TwoMegabytes)
{
// Don't download this attachment
return false;
}
}
// Fetch MIME part and include it in the returned MailMessage instance.
return true;
}
);
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.