How do I read mail on the server, programmatically?

Janne Lindh 46 Reputation points
2021-08-29T09:42:53.547+00:00

I have a VB program in Visual studio 2019 that reads mail folders to retrieve information like sender to create new contacts. Some folders don’t contain all data on the computer: ‘there are more items in this folder on the server’.

My question is how do I connect to the server to be able to read those mail?

Best regards
Janne

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
507 questions
0 comments No comments
{count} votes

Accepted answer
  1. Glen Scales 4,431 Reputation points
    2021-09-13T00:21:15.603+00:00

    • The text that is retrieved is HTML that is not so easy to analyze.

    You can set format you the Body you want returned using the bodyType https://learn.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.bodytype?view=exchange-ews-api

    >However, I do not know how to do if I want to connect to some special folder.

    If its a User Created Folder you need to use FindFolder to search for that folder based on it name eg something like https://www.vbforums.com/showthread.php?729451-Custom-EWS-Class-FindFolders-help

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Glen Scales 4,431 Reputation points
    2021-08-29T23:40:40.113+00:00

    Depending on the version of Exchange (eg OnPrem, Office365) look at using either EWS (onPrem) https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/get-started-with-ews-managed-api-client-applications or the Graph API for Office365 https://developer.microsoft.com/en-us/graph/get-started


  2. Janne Lindh 46 Reputation points
    2021-08-30T08:19:34.14+00:00

    Thank you for the reply.

    Most examples I have found until now describes code in c#. Since I am only familiar with VB, I cannot use them.

    Do you know where I can find example code in VB?

    Best regards
    Janne


  3. Janne Lindh 46 Reputation points
    2021-08-31T09:43:43.81+00:00

    Thanks for your advice. I will try a small experiment.

    It is VB.net. I have never tried VBA in Visual Studio. Is that possible?