Vuk Stanojevic

Vuk Stanojevic

  • 1.9k
  • 62
  • 1.5k

C# show emails in listview

Mar 25 2020 9:10 AM
Hi everyone,
im trying to show all my emails from mail.live.com in listview.
I try with follwoing code, but nothing happen.
Can you help me please?
 
 
ExchangeService exchange = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
exchange.Credentials = new WebCredentials("emailaddress", "password", "mail.live.com");
exchange.AutodiscoverUrl("emailadress");
if (exchange != null)
{
FindItemsResults<Item> result = exchange.FindItems(WellKnownFolderName.Inbox, new ItemView(1000));
foreach (Item item in result)
{
EmailMessage message = EmailMessage.Bind(exchange, item.Id);
string from = message.From.ToString();
string body = message.Body.Text;
try
{
ListViewItem item1 = new ListViewItem(from);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}

Brought to you by:

Answers (3)