Try
Dim svc As New ExchangeService()
svc.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
svc.Credentials = New WebCredentials("svc_user@domain.com", "xxxx")
svc.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, "peter@domain.com")
Dim mail As New EmailMessage(svc)
mail.From = "peter@domain.com"
mail.Subject = "Test Peter svc user"
mail.Body = "Test Body"
mail.ToRecipients.Add("tom@domain.com")
mail.Save()
mail.SendAndSaveCopy()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
But with my newly created svc_user I kept getting the following error: "The request failed. The remote server returned an error: (401) Unauthorized". Enabling the traces on my service calls gave no extra info. After googling this error I found a lot of MSDN pages with a lot of different possible solutions, but all to no avail.
After a tip from a colleague I did what I should have done a lot sooner. Navigate to https://portal.office.com and tried logging in with the svc_user. I got nice clear message stating that my password had expired or that I should change my password on first usage. After doing this everything worked just fine and I felt a bit dumb for spending a couple of hours on this issue :-)