title: Sending email using EWS in c# from shared mailbox
body: <p>The IT department is moving away from creating a service account to shared mailbox. All of our department email accounts are being converted to shared mailbox. Until now, I had been using EWS to send email from our web app to recipients using the following code: </p>
  
  <pre><code>ExchangeService service = new ExchangeService();
  service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
  {
       Credentials = new NetworkCredential("dept_email@example.com", "Password1"),
       Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx")
              };
  
       email = new EmailMessage(service);
       email.Body = new MessageBody(BodyType.HTML, Message.ToString());
       email.ToRecipients.Add(Recipient.email);
       email.SendAndSaveCopy();
  }
  </code></pre>
  
  <p>How can I use shared mailbox for sending emails instead of having hard coding email address and password? The email address I use is the service account that doesn't fall in the current password security criteria. It is because of this reason, they're changing department emails to shared mailbox. </p>
  
  <p>I'm using Windows Authentication that authenticates users from Active Directory. </p>