internal void SendMdmQuarantineEmail(bool isEnrolled) { using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.context.User.ExchangePrincipal, this.context.Request.Culture, "Client=ActiveSync;Action=MDMQuarantineMail")) { this.cultureInfo = mailboxSession.PreferedCulture; MicrosoftExchangeRecipient exchangeRecipient = this.organizationSettings.GetExchangeRecipient(); StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); using (MessageItem messageItem = MessageItem.CreateAssociated(mailboxSession, defaultFolderId)) { string empty = string.Empty; string empty2 = string.Empty; this.ConstructMDMQuarantineNotificationMail(isEnrolled, out empty, out empty2); messageItem.Subject = empty; using (TextWriter textWriter = messageItem.Body.OpenTextWriter(BodyFormat.TextHtml)) { textWriter.Write(empty2); } messageItem.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient)); messageItem.Recipients.Add(new Participant(mailboxSession.MailboxOwner), RecipientItemType.To); messageItem[MessageItemSchema.IsDraft] = false; messageItem[MessageItemSchema.IsRead] = false; messageItem.Save(SaveMode.NoConflictResolution); messageItem.Load(); this.context.ProtocolLogger.AppendValue(ProtocolLoggerData.GraphApiCallData, string.Format("qes:{0}", true)); this.globalInfo.ABQMailId = messageItem.Id.ObjectId; this.globalInfo.ABQMailState = ABQMailState.MailPosted; } } }
private void CreateNotification(IEnumerable <ExchangeCertificate> certificates, bool isExpired) { ADRecipientOrAddress owner = null; MicrosoftExchangeRecipient microsoftExchangeRecipient = this.adSession.FindMicrosoftExchangeRecipient(); if (microsoftExchangeRecipient == null) { this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_MicrosoftExchangeRecipientNotFoundException, string.Empty, new object[] { string.Empty }); } else { owner = new ADRecipientOrAddress(new Participant(microsoftExchangeRecipient)); } foreach (ExchangeCertificate exchangeCertificate in certificates) { KeyValuePair <string, LocalizedString>[] extendedAttributes = new KeyValuePair <string, LocalizedString>[] { new KeyValuePair <string, LocalizedString>("ServerName", new LocalizedString(this.serverObj.Name)), new KeyValuePair <string, LocalizedString>("ServerFqdn", new LocalizedString(this.serverObj.Fqdn)), new KeyValuePair <string, LocalizedString>("ThumbPrint", new LocalizedString(exchangeCertificate.Thumbprint)), new KeyValuePair <string, LocalizedString>("FriendlyName", new LocalizedString(exchangeCertificate.FriendlyName)), new KeyValuePair <string, LocalizedString>("ExpireDate", new LocalizedString(exchangeCertificate.NotAfter.ToFileTimeUtc().ToString())) }; string id = this.serverObj.Fqdn + "\\" + exchangeCertificate.Thumbprint; AsyncOperationNotificationDataProvider.CreateNotification(this.orgId, id, AsyncOperationType.CertExpiry, isExpired ? AsyncOperationStatus.CertExpired : AsyncOperationStatus.CertExpiring, new LocalizedString(exchangeCertificate.FriendlyName), owner, extendedAttributes, false); AsyncOperationNotificationDataProvider.SendNotificationEmail(this.orgId, id, false, null, false); } }
internal void SendABQNotificationMail() { using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.context.User.ExchangePrincipal, this.context.Request.Culture, "Client=ActiveSync;Action=ABQMail")) { this.cultureInfo = mailboxSession.PreferedCulture; MicrosoftExchangeRecipient exchangeRecipient = this.organizationSettings.GetExchangeRecipient(); StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); using (MessageItem messageItem = MessageItem.Create(mailboxSession, defaultFolderId)) { this.ConstructUserNotificationMail(messageItem); messageItem.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient)); messageItem.Recipients.Add(new Participant(mailboxSession.MailboxOwner), RecipientItemType.To); messageItem[MessageItemSchema.IsDraft] = false; messageItem[MessageItemSchema.IsRead] = false; messageItem.Save(SaveMode.NoConflictResolution); messageItem.Load(new PropertyDefinition[0]); this.globalInfo.ABQMailId = messageItem.Id.ObjectId; this.globalInfo.ABQMailState = ABQMailState.MailPosted; } defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts); if (this.globalInfo.DeviceAccessState == DeviceAccessState.Quarantined) { using (MessageItem messageItem2 = MessageItem.Create(mailboxSession, defaultFolderId)) { foreach (SmtpAddress smtpAddress in this.organizationSettings.AdminMailRecipients) { Participant participant; if (smtpAddress.IsValidAddress && Participant.TryParse(smtpAddress.ToString(), out participant) && participant != null) { messageItem2.Recipients.Add(participant, RecipientItemType.To); } } if (messageItem2.Recipients.Count > 0) { this.ConstructAdminNotificationMail(messageItem2); messageItem2.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient)); messageItem2.SendWithoutSavingMessage(); } else { AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "ABQMail:No valid AdminMailRecipients to send Admin mail to!"); if (VariantConfiguration.InvariantNoFlightingSnapshot.ActiveSync.ActiveSyncDiagnosticsLogABQPeriodicEvent.Enabled) { AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_NoAdminMailRecipientsError, "NoAdminMailRecipients", new string[0]); } } } } } }
internal void SendAutoBlockNotificationMail(TimeSpan blockTime, string adminEmailInsert) { using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.context.User.ExchangePrincipal, this.context.Request.Culture, "Client=ActiveSync;Action=AutoBlockMail")) { this.cultureInfo = mailboxSession.PreferedCulture; MicrosoftExchangeRecipient exchangeRecipient = this.organizationSettings.GetExchangeRecipient(); StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); using (MessageItem messageItem = MessageItem.Create(mailboxSession, defaultFolderId)) { this.ConstructAutoBlockNotificationMail(messageItem, blockTime, adminEmailInsert); messageItem.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient)); messageItem.Recipients.Add(new Participant(mailboxSession.MailboxOwner), RecipientItemType.To); messageItem[MessageItemSchema.IsDraft] = false; messageItem[MessageItemSchema.IsRead] = false; messageItem.Save(SaveMode.NoConflictResolution); } } }
// Token: 0x06001378 RID: 4984 RVA: 0x00050ADC File Offset: 0x0004ECDC private static void InternalPostMessage(MailboxSession session, string subject, string body, string messageId, string className, Importance?importance) { if (session == null) { throw new ArgumentNullException("subject"); } if (string.IsNullOrEmpty(subject)) { throw new ArgumentNullException("subject"); } if (string.IsNullOrEmpty(body)) { throw new ArgumentNullException("body"); } using (Folder folder = Folder.Bind(session, session.GetDefaultFolderId(DefaultFolderType.Inbox))) { if (!string.IsNullOrEmpty(messageId)) { QueryFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.InternetMessageId, messageId); using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, SystemMessageHelper.PropList)) { queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter); object[][] rows = queryResult.GetRows(1); if (rows.Length > 0) { return; } } } using (MessageItem messageItem = MessageItem.Create(session, folder.Id)) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(session.MailboxOwner.MailboxInfo.OrganizationId), 123, "InternalPostMessage", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\SystemMessageHelper\\SystemMessageHelper.cs"); if (tenantOrTopologyConfigurationSession.SessionSettings != null) { tenantOrTopologyConfigurationSession.SessionSettings.AccountingObject = session.AccountingObject; } MicrosoftExchangeRecipient microsoftExchangeRecipient = tenantOrTopologyConfigurationSession.FindMicrosoftExchangeRecipient(); if (microsoftExchangeRecipient != null) { messageItem.From = new Participant(microsoftExchangeRecipient); } messageItem.Subject = subject; messageItem.Recipients.Add(new Participant(session.MailboxOwner), RecipientItemType.To); messageItem[MessageItemSchema.IsDraft] = false; messageItem[MessageItemSchema.IsRead] = false; using (TextWriter textWriter = messageItem.Body.OpenTextWriter(BodyFormat.TextHtml)) { textWriter.Write(body); } if (!string.IsNullOrEmpty(messageId)) { messageItem.InternetMessageId = messageId; } if (!string.IsNullOrEmpty(className)) { messageItem.ClassName = className; } if (importance != null) { messageItem.Importance = importance.Value; } messageItem.Save(SaveMode.NoConflictResolution); } } }