Way to retreive the mails

Peter_1985 2,711 Reputation points
2025-03-04T04:53:04.7133333+00:00

Hi,

Is it a good way to use SmtpServer and retrieve all of the mails (of a period) to one mail account? And get all of the details of the mails?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,336 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiale Xue - MSFT 49,126 Reputation points Microsoft External Staff
    2025-03-04T06:29:14.0833333+00:00

    Hi @Peter_1985 , Welcome to Microsoft Q&A,

    Updated:

    Read https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=net-9.0 to find out that (SMTP) uses the Simple Mail Transfer Protocol to send emails. It is not used to receive emails.

    Refer to https://learn.microsoft.com/en-us/answers/questions/1791528/reading-emails-from-outlook-in-c .

    You can use MailKit to connect to an IMAP server.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Bruce (SqlWork.com) 72,596 Reputation points
    2025-03-17T17:16:37.8266667+00:00

    You are probably looking for a IMAP sdk. Microsoft does not supply one, only access to exchange and office 365 via the graph api (and obsolete ews sdk).

    https://learn.microsoft.com/en-us/graph/use-the-api

    you will need to find a 3rd party sdk. you may need modern features like oauth support, so be sure the sdk supports this. It is beyond the scope of this forum to recommend 3rd party solutions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.