I am trying to create a small web based mail client and I am using openpop to connect to the mail server, to download all new emails at the server. But I can't get the email of the receiver of the mail(my emailaddress). The mail I am connecting to is a "catch-all" account. So there are many different email addresses used when emailing me. (500 of them)

I've tried using this:

OpenPop.Mime.Message newMessage;
....
newMessage = client.GetMessage(i);
....
string mailA = newMessage.Headers.To.ToString();

But the output is:

System.Collections.Generic.List`1[OpenPop.Mime.Header.RfcMailAddress]

I guess that the problem is that I am trying to convert an object to a string.

Can someone help me?

Thanks!

有帮助吗?

解决方案

string mailto = "";
foreach (RfcMailAddress mailId in loadedMessage.Headers.To)
{
    mailto += mailId.MailAddress.ToString() + "; ";
}

This should give mail addresses in a string with a ; as delimiter.

其他提示

After some research I was able to solve it:

string emailA = "";

        foreach (OpenPop.Mime.Header.RfcMailAddress objectItem in newMessage.Headers.To)
        {
            emailA = objectItem.Address.ToString();
        }

A bit dirty This code doens't take care of multiple receivers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top