Sto usando OpenPop.net per provare e analizzare i nostri collegamenti da tutte le email che si trovano in una determinata casella di posta. Ho trovato questo metodo per ottenere tutto il messaggio:OpenPop.net visualizza il testo del messaggio attuale
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;
}
}
Ora sto cercando di collegare attraverso ogni messaggio, ma io non riesco a capire come farlo, ho questa finora per il mio tasto:
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);
}
Come potrei scorrere in loop ogni voce in allaEmail in modo che possa visualizzarla in un MessageBox?
WOW grazie foens! Era esattamente quello che stavo cercando! :) Checkbox in arrivo – user1213488
html.GetBodyAsText() dà un'eccezione dice che il riferimento all'oggetto non è impostato su un'istanza. ma ottengo il valore utilizzando FindFirstPlainTextVersion() e quindi plainText.GetBodyAsText() qualche idea del perché? – Antony