private void SendLocalizedEmail(MailboxSession session, NewExchangeNotification.NotificationEmailInfo emailInfo)
 {
     if (session == null)
     {
         throw new ArgumentNullException("session");
     }
     if (emailInfo.Recipients == null || emailInfo.Recipients.Count <SmtpAddress>() == 0)
     {
         return;
     }
     using (MessageItem messageItem = MessageItem.Create(session, session.GetDefaultFolderId(DefaultFolderType.Drafts)))
     {
         foreach (SmtpAddress smtpAddress in emailInfo.Recipients)
         {
             messageItem.Recipients.Add(new Participant(string.Empty, smtpAddress.ToString(), "SMTP"));
         }
         string eventCategory;
         string localizedEventMessageAndCategory = this.GetLocalizedEventMessageAndCategory(emailInfo.Language, out eventCategory);
         messageItem.Subject = Strings.TenantNotificationSubject(eventCategory, this.DataObject.EventDisplayId).ToString(emailInfo.Language);
         using (Stream stream = messageItem.Body.OpenWriteStream(new BodyWriteConfiguration(BodyFormat.TextHtml, Charset.Unicode)))
         {
             using (StreamWriter streamWriter = new StreamWriter(stream, Encoding.Unicode))
             {
                 string         helpUrlForNotification = this.GetHelpUrlForNotification(emailInfo.Language);
                 OrganizationId currentOrganizationId  = base.CurrentTaskContext.UserInfo.CurrentOrganizationId;
                 streamWriter.WriteLine(Strings.TenantNotificationBody(HttpUtility.HtmlEncode((currentOrganizationId == null) ? string.Empty : currentOrganizationId.GetFriendlyName()), HttpUtility.HtmlEncode(this.DataObject.EventTimeUtc.ToString("f", emailInfo.Language)), (!string.IsNullOrEmpty(localizedEventMessageAndCategory)) ? HttpUtility.HtmlEncode(localizedEventMessageAndCategory) : Strings.TenantNotificationUnavailableEventMessage.ToString(emailInfo.Language), HttpUtility.HtmlEncode(helpUrlForNotification)).ToString(emailInfo.Language));
             }
         }
         messageItem.AutoResponseSuppress = AutoResponseSuppress.All;
         messageItem.InternetMessageId    = emailInfo.MessageId;
         messageItem.SendWithoutSavingMessage();
     }
 }