0

Hi I am new to c# and have been asked to read in the title and contents of emails that arrive in a particular email account and them store them in SQL. I initially thought this must be easy but I cannot find any simple tutorials or samples.

Can anyone help?

Alfred Myers
  • 6,384
  • 1
  • 40
  • 68
Mick W
  • 1
  • 1
  • 1

1 Answers1

1

Check HERE: something similar already discussed. Mainly, you can use :

If you will use EWS here is some sample :

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); // depends from Exchange server version 
    //service.Credentials = new NetworkCredential( "{Active Directory ID}", "{Password}", "{Domain Name}" );
    service.AutodiscoverUrl( "First.Last@MyCompany.com" );
    FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox,
          new ItemView( 10 ) );
    foreach ( Item item in findResults.Items )
    {
       Console.WriteLine( item.Subject );
    }
Community
  • 1
  • 1
Incognito
  • 16,567
  • 9
  • 52
  • 74
  • Ok thanks for the help. I have since been told the exchange servers only have IMAP, the servers are a mix of exchange 2003 and 2007. So I am looking for some sample code for IMAP, either in C# or vbscript. Also there is no budget to buy libraries etc. I'm quite stuck here, any other helpful links would be greatfully received. Thanks – Mick W May 27 '10 at 09:24
  • this is a good sample. I tried to test in a console applictoin, but I get this error : "The Autodiscover service couldn't be located." when service.Autodiscover("mdr@domain.com"); is executed. I'm in the same domain so I don't pass credentials per API documentation. I've also installed the Exachange Webservice API per your reference. why is autodiscover not working? What else am I missing? thanks – ethem Jan 18 '11 at 09:02
  • @user472092 check here - http://social.technet.microsoft.com/Forums/en-US/exchange2010/thread/5617c82f-b0c3-4591-8a40-4fc590091ed9/ – Incognito Jan 18 '11 at 12:37