Tôi đang sử dụng OpenPop.net để thử và phân tích các liên kết của chúng tôi từ tất cả các email trong một hộp thư đến. Tôi thấy phương pháp này để có được tất cả các thông điệp:OpenPop.net nhận được tin nhắn văn bản thực tế
public static List<OpenPop.Mime.Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
}
client.Disconnect();
// Now return the fetched messages
return allMessages;
}
}
Bây giờ tôi đang cố gắng để lặp qua mỗi tin nhắn nhưng tôi dường như không thể tìm ra cách để làm điều đó, tôi có điều này cho đến nay cho nút của tôi:
private void button7_Click(object sender, EventArgs e)
{
List<OpenPop.Mime.Message> allaEmail = FetchAllMessages("pop3.live.com", 995, true, "[email protected]", "xxxxx");
var message = string.Join(",", allaEmail);
MessageBox.Show(message);
}
Làm cách nào tôi lặp qua từng mục trong allaEmail để tôi có thể hiển thị nó trong một MessageBox?
WOW cảm ơn bạn! Đó là chính xác những gì tôi đã sau! :) Checkbox comming – user1213488
html.GetBodyAsText() đưa ra một ngoại lệ cho biết đối tượng không được thiết lập cho một cá thể. nhưng tôi nhận được giá trị bằng cách sử dụng FindFirstPlainTextVersion() và sau đó plainText.GetBodyAsText() bất kỳ ý tưởng tại sao? – Antony