forked from doithaylaem/mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mail.cs
29 lines (27 loc) · 892 Bytes
/
Mail.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using (var client = new Pop3Client())
{
try
{
client.Connect("gunmail.xyz", 110, MailKit.Security.SecureSocketOptions.None);
client.Authenticate("[email protected]", "12345678");
int messageCount = client.Count;
Console.WriteLine($"Total messages: {messageCount}");
for (int i = 0; i < messageCount; i++)
{
MimeMessage message = client.GetMessage(i);
Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"From: {message.From}");
Console.WriteLine($"Date: {message.Date}");
Console.WriteLine("--------------------------------------------");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
finally
{
// Disconnect from the server
client.Disconnect(true);
}
}