Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 03 14:38
    jstedfast closed #1297
  • Dec 03 14:38
    jstedfast commented #1297
  • Dec 03 14:38
    jstedfast labeled #1297
  • Dec 03 14:30
    eugenestepanyuk opened #1297
  • Dec 03 14:29
    jstedfast commented #266
  • Dec 03 14:28
    jstedfast commented #266
  • Dec 03 14:26
    jstedfast closed #1296
  • Dec 03 14:26
    jstedfast commented #1296
  • Dec 03 14:19
    jstedfast labeled #1296
  • Dec 03 13:08
    eugenestepanyuk commented #266
  • Dec 03 08:59
    dheoxic edited #1296
  • Dec 03 08:56
    dheoxic opened #1296
  • Dec 02 16:57
    jstedfast closed #1295
  • Dec 02 16:57
    jstedfast commented #1295
  • Dec 02 16:57
    jstedfast labeled #1295
  • Dec 02 15:58
    eugenestepanyuk opened #1295
  • Dec 01 14:46
    jstedfast closed #1294
  • Dec 01 14:46
    jstedfast commented #1294
  • Dec 01 14:41
    jstedfast labeled #1294
  • Dec 01 14:41
    jstedfast commented #1294
Jeffrey Stedfast
@jstedfast
and then calling client.GetMessage (index); :)
Michael Chandler
@optiks
Heya. This isn't a MailKit specific question, but I'm just wondering if you have any suggestions for libraries that can stub an IMAP server?
We've got an existing product which uses MailKit to poll an IMAP server. We're now looking at adding automated tests, and it'd be nice to be able to stub which emails and attachments are returned.
(We could do this through DI and interfaces, but I'd prefer to test this as closely to end-to-end as possible for now.)
ANANDHASTEVE
@ANANDHASTEVE
How to add a X509Certificate2 present in WIndows personal store while connecting with smtpClient in Tsl2 using SmtpClient.ClientCertificates.Add method ? Can any one help me ? Thanks.
Saurbaum
@Saurbaum
Out of curiosity. If someone had a certificate setup properly on their server but configured mailkit to connect by ip address instead of the DNS name would they see the same error as if they had used a self signed certificate? i.e. "The remote certificate is invalid according to the validation procedure"
Jeffrey Stedfast
@jstedfast
@Saurbaum that's a good question because I think certificate validation might use the hostname (this logic would live in SslStream if it exists)
I'm not entirely sure, though.
Saurbaum
@Saurbaum
Thanks.
Something else I've been wondering. Is an internet connection required for any of the certificate validation/revocation checks? If proper root certificates are installed can this all work in a private network? My testing was all done with an internet connection but naturally people are trying to use it in an environment that differs greatly from my own.
Jeffrey Stedfast
@jstedfast
@Saurbaum a network connection is needed for revocation checks and I think is also used if the user doesn't have the full chain of certificates.
ghendo
@ghendo
If I send email using mailkit smtp should I expect the outgoing mail to be in the sent mailbox for the user?
Jeffrey Stedfast
@jstedfast
@ghendo no, if you want the message to be added to the sent folder, you'll need to connect to the IMAP server and Append() it to the folder
ghendo
@ghendo
Ahh ok
ghendo
@ghendo
Does that mean I need to send it by smtp AND append it to the IMAP folder?
Jeffrey Stedfast
@jstedfast
yes
0marron
@0marron
hello
ghendo
@ghendo
hello
ghendo
@ghendo
If I have a MimeMessage with attachments which I send then I wish to place the message in the sent mail box I am finding the stream for the attachments is closed so fails. What is best strategy to handle this?
JAVIER MATIAS
@javiermatias
Hi people! How are you? with mailkit could i do a server of IMAP?
Jeffrey Stedfast
@jstedfast
@javiermatias MailKit isn't really designed to write a server, but should be able to use MimeKit
@ghendo MailKit doesn't close the streams, so your code must be doing that somewhere else
ghendo
@ghendo
regarding custom flags I was hoping to be able to have a mailbox query based on does not have custom flag but I note this query is marked deprecated. What do suggest if I wish to mark a message with a user defined flag and search the mailbox for items that dont have this flag?
ghendo
@ghendo
I tried setting thae custom flag and query by NotKeyword but I dont think it is setting the custom flag
    public async Task<List<EmailMessage>> ReceiveEmailAsync(int maxCount = 10)
    {
        List<EmailMessage> emailMessages = new List<EmailMessage>();

        HashSet<string> customFlags = new HashSet<string>();
        customFlags.Add("esigread");//  means esignature system has read this message
        try
        {
            using (var imapClient = new ImapClient())
            {
                imapClient.AuthenticationMechanisms.Remove("XOAUTH2");
                imapClient.ServerCertificateValidationCallback = (s, c, h, e) => true;

                await imapClient.ConnectAsync("gpts.dnsalias.com", 993, true).ConfigureAwait(false);

                await imapClient.AuthenticateAsync("esignatures@onsitecleaning.com.au", "F&3h*h({17!").ConfigureAwait(false);
                await imapClient.Inbox.OpenAsync(FolderAccess.ReadWrite).ConfigureAwait(false);
                var uids = await imapClient.Inbox.SearchAsync(SearchQuery.NotKeyword("esigread")).ConfigureAwait(false);
                foreach (var uid in uids)
                {
                    var message = await imapClient.Inbox.GetMessageAsync(uid).ConfigureAwait(false);
                    //await imapClient.Inbox.AddFlagsAsync(uid,MessageFlags.Seen,false).ConfigureAwait(false);
                    await imapClient.Inbox.AddFlagsAsync(uid, MessageFlags.UserDefined,customFlags, false).ConfigureAwait(false);
                    EmailMessage emailMessage = new EmailMessage()
                    {
                        ContentHtml = message.HtmlBody,
                        ContentText = message.TextBody,
                        Subject = message.Subject,
                        TextBody = message.TextBody,
                        HtmlBody = message.HtmlBody,
                        ToAddresses = new List<EmailAddress>() { new EmailAddress() { Address = message.To.Mailboxes.FirstOrDefault().Address } },
                        FromAddresses = new List<EmailAddress>() { new EmailAddress() { Address = message.From.Mailboxes.FirstOrDefault().Address } },
                    };
                    emailMessages.Add(emailMessage);
                }

                imapClient.Disconnect(true);
            }

            return emailMessages;
        }
        catch (Exception ex)
        {

            throw;
        }

    }
Jeffrey Stedfast
@jstedfast
@ghendo make sure that the imapClient.Inbox.PermanentFlags.HasFlag (MessageFlags.UserDefined)
otherwise the custom keywords will not be persisted
ghendo
@ghendo
so the userdefined message flag is a thing that the server supports or doesnt so I am unable to set it?
Jeffrey Stedfast
@jstedfast
Correct
sleepyheadbensh
@bensh90
Hi there :) I have a Question, I'm using the Mailkit Library to read E-Mails with IMAP Protocool. But I am unable to connect when using a Proxy. How can I set the ProxyClient Property of the ImapClient Class? as It's an Abstract Class I can't instantiate it. And i can't find a set Method or something similar.
Jeffrey Stedfast
@jstedfast
client.ProxyClient new HttpProxyClient (...); or new Socks5ProxyClient(...)
sleepyheadbensh
@bensh90
Ah thanks, i thought I would need this exact object. I didn't know it's the same as a httpProxyClient object
Rabbee Fazley
@rfazley1_twitter

Hi, I've just started using MailKit using a c# project to tidy my yahoo mail box which has grown over the years - working great so far. I've already removed over 10k emails!

Is there a way I can get a count of unread messages by the sender, say where the count is greater than 250?

Jeffrey Stedfast
@jstedfast
@rfazley1_twitter you can do that several ways and I'm not sure which will be faster
@rfazley1_twitter you can either do var summaries = folder.Fetch (0, -1, MessageSummaryItems.Envelope | MessageSummaryItems.Flags); and then manually sort each result into lists using if (summaries[i].Flags.HasValue && !summaries[i].Flags.Value.HasFlag (MessageFlags.Seen)) unreadCounts[summaries[i].Envelope.From.Mailboxes.FirstOrDefault()?.Address] += 1;
or, actually... better yet...
Jeffrey Stedfast
@jstedfast
var uids = folder.Search (SearchQuery.NotSeen); var summaries = folder.Fetch (uids, MessageSummaryItems.Envelope | MessageSummaryItems.Flags); var unreadCounts = new Dictionary<string, int>(); foreach (var summary in summaries) if (summary.Flags.HasValue && !summary.Flags.Value.HasFlag (MessageFlags.Seen)) unreadCounts[summary.Envelope.From.Mailboxes.FirstOrDefault()?.Address] += 1;
then... foreach (var sender in unreadCounts) { if (sender.Value > 250) ... }
Rabbee Fazley
@rfazley1_twitter
Excellent, thank you for the quick response, I have it working now. I ended up also using a linq query to group by the sender, subject etc where the count was greater than 250.
Markus Ziegler
@Kingviech

Hello, sorry i don't know if this is the right place to ask this question, but here I go:

do any of you have any experience with checking the availability of MS Exchange servers before connecting to it with mailkit?

I get authentication errors during downtimes of a customer (LOGIN FAILED by exchange when some components are down, maybe it is blocking requests during down times, idk), which I use to stop the imap sync to prevent user lockouts from their active directory.

Jeffrey Stedfast
@jstedfast
@Kingviech Unfortunately I do not have an answer :( Is there more to it than just pinging the Exchange server to see if ti is up?
Markus Ziegler
@Kingviech

Yeah I am already pinging the server, but the server still returns a success during the ping, it looks like a port listener is up during the downtime (I check the availability by opening a tcp socket to the IMAP port and check if it fails), but it returns a valid IMAP Response LOGIN FAILED over the IMAP connection, as if it was intentionally blocking IMAP connections during the downtime (which is okay, but the login failed message is misleading)

It looks like something Exchange specific, I will check the documentation for exchange integrations if there is anything i can do to check if the IMAP Service is online

Thanks for the reply :-)

RedlineTriad
@RedlineTriad

I am not sure if this is something that I should not allow happening or if it's a MailKit issue.

MailboxAddress.Parse("test.test.@test.com")

throws a MikeKit.ParseException the reason is the . before the @.
Is this correct or a bug?

Jeffrey Stedfast
@jstedfast
it is correct
Andrey Petukhov
@andreypetukhov
hi, any expectation to support .net 5?
Jeffrey Stedfast
@jstedfast
already supported
Daniel Rivero
@Danyfirex_gitlab
Hello guys. I've read and search many times and I've not found a way to get FLAGS or PERMANENTFLAGS user defined keywords. is there a way to get them?
Jeffrey Stedfast
@jstedfast
If you can wait a day or 2, I can probably add support for this to the vnext branch of MailKit
Daniel Rivero
@Danyfirex_gitlab
Thank you very much Jeffrey You're are amazing
Jeffrey Stedfast
@jstedfast
No prob, and thank you :)