I wanted to export a list of all email addresses I had corresponded with and was unable to find a free product to compile the list so I came up with this. You could take it a step further and scrape additional email addresses from the message body.
As far as calling the code:
void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(s => DoWork());
}
void DoWork()
{
OutlookEmailAddressExtractor extractor = new OutlookEmailAddressExtractor();
string[] emails = extractor
.GetAllAddress()
.Where(addr => !string.IsNullOrEmpty(addr) && addr.Contains("@") && !addr.Contains(",") && !addr.Contains("="))
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(s => s)
.ToArray();
string csv = string.Join(", ", emails);
//save the csv list...
string lst = string.Join(Environment.NewLine, emails);
//save the list...
Debugger.Break();
}