‘Autodiscover service couldn’t be located’ when trying to access Exchange 2010 account with EWS MANAGED API

You got Service.Credentials wrong, use it like this: Service.Credentials = new WebCredentials(username, password, domainname); Using domain credentials, not the email address. Also doublecheck the following: The version you specify in new ExchangeService() matches server’s the parameter passed to Service.AutodiscoverUrl(); is correct (email address which data needs to be fetched) The following works for me (in … Read more

Get current user’s email address in .NET [closed]

Reference System.DirectoryServices.AccountManagement, then using System.DirectoryServices.AccountManagement; return UserPrincipal.Current.EmailAddress; See .NET docs UserPrincipal.Current and UserPrincipal.EmailAddress. Or with a timeout: var task = Task.Run(() => UserPrincipal.Current.EmailAddress); if (task.Wait(TimeSpan.FromSeconds(1))) return task.Result;

Reading e-mails from Outlook with Python through MAPI

I had the same problem you did – didn’t find much that worked. The following code, however, works like a charm. import win32com.client outlook = win32com.client.Dispatch(“Outlook.Application”).GetNamespace(“MAPI”) inbox = outlook.GetDefaultFolder(6) # “6” refers to the index of a folder – in this case, # the inbox. You can change that number to reference # any other … Read more

Publishing Outlook Calendars. What is the server-side setting for sync frequency?

CalDAV (Calendaring Extensions to WebDAV, documented in RFC-4791) uses the iCalendar (Internet Calendaring and Scheduling Core Object Specification, documented in RFC-5545, not to be confused with Apple’s iCal) format for the data exchange. iCalendar accommodates non-standard properties that start with a “X-” prefix. X-PUBLISHED-TTL is the property that maps to the recommended update interval for … Read more

Send SMTP email using System.Net.Mail via Exchange Online (Office 365)

Fixed a few typos in the working code above: MailMessage msg = new MailMessage(); msg.To.Add(new MailAddress(“someone@somedomain.com”, “SomeOne”)); msg.From = new MailAddress(“you@yourdomain.com”, “You”); msg.Subject = “This is a Test Mail”; msg.Body = “This is a test message using Exchange OnLine”; msg.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(“your user … Read more

Retrieve calendar items (Outlook API, WebDAV) displaying strange behaviour

Possible cause: Sort after setting IncludeRecurrences. Here is my code of a PowerShell module that retrieves Outlook items between two dates. And a little applet to check for changes and send an email including the agenda updates, which comes handy when you don’t have mobile access to the Exchange. Path: Documents\WindowsPowerShell\Modules\Outlook\expcal.ps1 Function Get-OutlookCalendar { <# … Read more

EWS API – Error when recreating notification subscriptions

Given the documentation at: https://msdn.microsoft.com/en-us/library/office/dn458788(v=exchg.150).aspx When a subscription is lost, or is no longer accessible, it is best to create a new subscription and not include the old watermark in the new subscription. Resubscribing with the old watermark causes a linear scan for events, which is costly. Instead, create a new subscription and compare folder … Read more

Read MS Exchange email in C#

It’s a mess. MAPI or CDO via a .NET interop DLL is officially unsupported by Microsoft–it will appear to work fine, but there are problems with memory leaks due to their differing memory models. You could use CDOEX, but that only works on the Exchange server itself, not remotely; useless. You could interop with Outlook, … Read more