I have been developing an email client within Visual Studio 2019 using C#. While also using the Microsoft.Exchange.WebServices library.
I need to connect to an email, but that email has sub accounts on it.
Example:
I have no idea how to connect to the sub account or if you can?
// The code used to connect to an email address.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials(Email, Password, Domain);
service.Url = new Uri(Asmx);
There is no such thing as a sub account in Exchange you just have mailboxes and a Mailbox maybe assigned more the one Email Address. Or you may have a Delegate Mailbox or Shared Mailbox which are separate mailbox that you may have been granted access to.
The code you posted just finds the best CAS Endpoint for EWS for the credentials you used it has nothing to do with connecting to a mailbox. If you want to access a Mailbox other then those of the credentials you using then you should just be using the FolderId overload to specify the Mailbox you want to access. eg if your shared Mailbox was called Shared@domain.com then use
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox,"Shared@domain.com");
ItemView itemView = new ItemView(1000);
service.FindItems(SharedMailbox,itemView);