public void SendNotification()
        {
            EmailNotificationHandler.Tracer.TraceDebug <string>((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Processing notifications for Group {0}.", this.groupMailbox.ExternalDirectoryObjectId);
            IExtensibleLogger logger = MailboxAssociationDiagnosticsFrameFactory.Default.CreateLogger(this.groupMailbox.ExchangeGuid, this.groupMailbox.OrganizationId);
            IMailboxAssociationPerformanceTracker performanceTracker = MailboxAssociationDiagnosticsFrameFactory.Default.CreatePerformanceTracker(null);

            using (MailboxAssociationDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("EmailNotificationHandler", "SendNotification", logger, performanceTracker))
            {
                GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "EmailNotificationHandler.SendNotification", delegate
                {
                    using (MailboxSession session = MailboxSession.OpenAsTransport(this.exchangePrincipal, this.clientInfoString))
                    {
                        EmailNotificationHandler.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Created transport session for mailbox {0}. Group {1}.", session.MailboxGuid, this.groupMailbox.ExternalDirectoryObjectId);
                        StoreObjectId draftsFolderId = session.GetDefaultFolderId(DefaultFolderType.Drafts);
                        while (!this.pendingRecipients.IsEmpty)
                        {
                            IMailboxLocator recipient;
                            while (this.pendingRecipients.TryDequeue(out recipient))
                            {
                                performanceTracker.IncrementAssociationsRead();
                                GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "EmailNotificationHandler.ComposeAndDeliverMessage", delegate
                                {
                                    this.ComposeAndDeliverMessage(session, draftsFolderId, recipient, performanceTracker, logger);
                                }, (Exception e) => !(e is StoragePermanentException) && GrayException.IsGrayException(e));
                            }
                        }
                    }
                }, new Predicate <Exception>(GrayException.IsGrayException));
            }
            EmailNotificationHandler.Tracer.TraceDebug((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Task completed.");
        }
        private void StampMailboxForELCEHAProcessing(MailboxSession session)
        {
            string clientInfoString = "Client=TimeBased;Action=TransportEHAMailboxStamping";

            using (MailboxSession mailboxSession = MailboxSession.OpenAsTransport(session.MailboxOwner, clientInfoString))
            {
                mailboxSession.MarkAsEhaMailbox();
            }
        }
        // Token: 0x060006D9 RID: 1753 RVA: 0x000147E4 File Offset: 0x000129E4
        internal MailboxSession CreateMailboxSession(ExchangePrincipal exchangePrincipal, CultureInfo cultureInfo, string userContextString)
        {
            ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaWindowsIdentity.CreateMailboxSession");
            MailboxSession result;

            try
            {
                MailboxSession mailboxSession = MailboxSession.OpenAsTransport(exchangePrincipal, userContextString);
                result = mailboxSession;
            }
            catch (AccessDeniedException innerException)
            {
                throw new OwaExplicitLogonException("User has no access rights to the mailbox", "ErrorExplicitLogonAccessDenied", innerException);
            }
            return(result);
        }
        private void CreateSessionInternal(MailRecipient recipient, OpenTransportSessionFlags deliveryFlags, DeliverableItem item, ICollection <CultureInfo> recipientLanguages, bool useCompletePrincipal)
        {
            bool isPublicFolderRecipient   = this.IsPublicFolderRecipient(item);
            ExchangePrincipal principal    = this.GetExchangePrincipalForRecipient(recipient, item, recipientLanguages, useCompletePrincipal);
            string            databaseName = this.context.MbxTransportMailItem.DatabaseName;

            this.LogConnection(databaseName, "Mailbox");
            this.RunUnderOpenStoreSessionFailedLogger(databaseName, delegate
            {
                if (isPublicFolderRecipient)
                {
                    this.storeSession = PublicFolderSession.OpenAsTransport(principal, deliveryFlags);
                    return;
                }
                this.storeSession = MailboxSession.OpenAsTransport(principal, deliveryFlags);
            });
            if (!isPublicFolderRecipient)
            {
                this.storeSession.ExTimeZone = ExTimeZone.CurrentTimeZone;
            }
        }
Exemple #5
0
        private DeletionResult DeleteMessageFromOutboxHelper(DeleteMapiMailDefinition deleteMapiMailDefinition)
        {
            DeletionResult    result = DeletionResult.Fail;
            string            domainPartOfEmailAddress = MapiMessageSubmitter.GetDomainPartOfEmailAddress(deleteMapiMailDefinition.SenderEmailAddress);
            ExchangePrincipal mailboxOwner             = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domainPartOfEmailAddress), deleteMapiMailDefinition.SenderEmailAddress);
            QueryFilter       queryFilter = new AndFilter(new List <QueryFilter>(2)
            {
                new TextFilter(ItemSchema.InternetMessageId, deleteMapiMailDefinition.InternetMessageId, MatchOptions.FullString, MatchFlags.IgnoreCase),
                new TextFilter(StoreObjectSchema.ItemClass, deleteMapiMailDefinition.MessageClass, MatchOptions.FullString, MatchFlags.IgnoreCase)
            }.ToArray());

            using (MailboxSession mailboxSession = MailboxSession.OpenAsTransport(mailboxOwner, "Client=Monitoring;Action=MapiSubmitLAMProbe"))
            {
                using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Outbox))
                {
                    using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, queryFilter, null, new PropertyDefinition[]
                    {
                        ItemSchema.Id
                    }))
                    {
                        object[][] rows = queryResult.GetRows(1);
                        if (rows == null || rows.Length == 0)
                        {
                            result = DeletionResult.NoMatchingMessage;
                        }
                        else
                        {
                            mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                            {
                                ((VersionedId)rows[0][0]).ObjectId
                            });
                            result = DeletionResult.Success;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #6
0
        private void SendMapiMessageHelper(bool setLamNotificationId, string lamNotificationId, SendMapiMailDefinition mapiMailDefinition, bool returnOutParameters, out string entryId, out string internetMessageId, out Guid senderMbxGuid)
        {
            entryId           = string.Empty;
            internetMessageId = string.Empty;
            senderMbxGuid     = Guid.Empty;
            ExchangePrincipal mailboxOwner;

            if (mapiMailDefinition.SenderMbxGuid != Guid.Empty)
            {
                mailboxOwner = ExchangePrincipal.FromMailboxData(mapiMailDefinition.SenderMbxGuid, mapiMailDefinition.SenderMdbGuid, new List <CultureInfo>(0));
            }
            else
            {
                string domainPartOfEmailAddress = MapiMessageSubmitter.GetDomainPartOfEmailAddress(mapiMailDefinition.SenderEmailAddress);
                mailboxOwner = ExchangePrincipal.FromProxyAddress(ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(domainPartOfEmailAddress), mapiMailDefinition.SenderEmailAddress);
            }
            using (MailboxSession mailboxSession = MailboxSession.OpenAsTransport(mailboxOwner, "Client=Monitoring;Action=MapiSubmitLAMProbe"))
            {
                using (MessageItem messageItem = MessageItem.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Outbox)))
                {
                    messageItem.ClassName = mapiMailDefinition.MessageClass;
                    if (setLamNotificationId)
                    {
                        messageItem[MessageItemSchema.MapiSubmitLamNotificationId] = lamNotificationId;
                        messageItem[MessageItemSchema.XLAMNotificationId]          = lamNotificationId;
                    }
                    messageItem[MessageItemSchema.DoNotDeliver] = (mapiMailDefinition.DoNotDeliver ? "Supress" : "Deliver");
                    if (mapiMailDefinition.DropMessageInHub)
                    {
                        messageItem[MessageItemSchema.DropMessageInHub] = "FrontEnd-CAT-250";
                        messageItem[MessageItemSchema.SystemProbeDrop]  = "OnEndOfHeaders";
                    }
                    messageItem.Subject = mapiMailDefinition.MessageSubject;
                    BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextPlain);
                    using (TextWriter textWriter = messageItem.Body.OpenTextWriter(configuration))
                    {
                        textWriter.Write(mapiMailDefinition.MessageBody);
                    }
                    messageItem.Recipients.Add(new Participant(mapiMailDefinition.RecipientEmailAddress, mapiMailDefinition.RecipientEmailAddress, "SMTP"), RecipientItemType.To);
                    if (mapiMailDefinition.DeleteAfterSubmit)
                    {
                        messageItem.SendWithoutSavingMessage();
                    }
                    else
                    {
                        messageItem.Send();
                    }
                    if (returnOutParameters)
                    {
                        senderMbxGuid = mailboxSession.MailboxGuid;
                        messageItem.Load(new PropertyDefinition[]
                        {
                            StoreObjectSchema.EntryId,
                            ItemSchema.InternetMessageId
                        });
                        object obj      = messageItem.TryGetProperty(StoreObjectSchema.EntryId);
                        byte[] entryId2 = (byte[])obj;
                        entryId = MapiMessageSubmitter.EntryIdString(entryId2);
                        object obj2 = messageItem.TryGetProperty(ItemSchema.InternetMessageId);
                        internetMessageId = obj2.ToString();
                    }
                }
            }
        }
Exemple #7
0
        public MailboxSession OpenStore(OrganizationId organizationId, string displayName, string mailboxFqdn, string mailboxServerDN, Guid mailboxGuid, Guid mdbGuid, MultiValuedProperty <CultureInfo> senderLocales, MultiValuedProperty <Guid> aggregatedMailboxGuids)
        {
            ExchangePrincipal mailboxOwner = ExchangePrincipal.FromMailboxData(ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), displayName, mailboxFqdn, mailboxServerDN, string.Empty, mailboxGuid, mdbGuid, string.Empty, senderLocales, aggregatedMailboxGuids);

            return(MailboxSession.OpenAsTransport(mailboxOwner, "Client=HUB"));
        }