Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3341544
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:44:04+00:00 2026-05-18T00:44:04+00:00

Im trying to write a simple sample program which checks for any new mail

  • 0

Im trying to write a simple sample program which checks for any new mail on an Exchange 2010 server. As far as I can tell, the code I’ve got should work fine.

I setup the service as follows:

ExchangeService service = new ExchangeService();

service.Credentials = new WebCredentials("user@domain.co.uk", "password");

service.Url = new Uri("https://address/owa");

Upon executing the following code:

        int unreadMail = 0;

        // Add a search filter that searches on the body or subject.
        List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
        searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Defense"));

        // Create the search filter.
        SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());

        // Create a view with a page size of 50.
        ItemView view = new ItemView(50);

        // Identify the Subject and DateTimeReceived properties to return.
        // Indicate that the base property will be the item identifier
        view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived);

        // Order the search results by the DateTimeReceived in descending order.
        view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);

        // Set the traversal to shallow. (Shallow is the default option; other options are Associated and SoftDeleted.)
        view.Traversal = ItemTraversal.Shallow;

        // Send the request to search the Inbox and get the results.
        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view);

        // Process each item.
        foreach (Item myItem in findResults.Items)
        {
            if (myItem is EmailMessage)
            {
                if (myItem.IsNew) unreadMail++;

            }
        }

I get this error (on the FindItemResults line):

'>' is an unexpected token. The expected token is '"' or '''. Line 1, position 63.

This appears to be an error in the XML the API is actually generating, I’ve tried a few different lots of code (all along the same lines) and not found anything that works.

Any ideas? At a bit of a loss when it comes directly from the API!

Cheers, Daniel.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:44:05+00:00Added an answer on May 18, 2026 at 12:44 am

    Nevermind, fixed it – needed to point my service to:

    https://servername/ews/Exchange.asmx

    and provide regular domain login details such as “username”, “password” in order to connect!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple program in VC++ which will just initialize the
I'm trying to write a simple mail retrieval program in python. It seems the
I'm just starting out writing trying to write a simple program in C and
I am trying to write a really simple Outlook VSTO add in that checks
I'm trying to write a simple program that will receive a string of max
I'm trying to write a simple thread pool program in pthread. However, it seems
I'm trying to write a simple java applet program, but it seems that I'm
I am trying to write a simple program that lets me overlay a dot
I'm using Visual Studio 2010. I'm trying to write simple Camera class in OpenGL.
I'm trying to write a graphical program in C++ with QT where users can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.