Ejemplo n.º 1
0
        // do not use multiple dot notation when processing  messages in a loop
        // http://groups.yahoo.com/neo/groups/Outlook-Redemption/conversations/topics/6568
        private RDOMail CreateEmail(string senderEmailAddress, SenderEmailAccountType senderEmailAccountType, Response response)
        {
            RDOMail mail = null;
            if (senderEmailAccountType == SenderEmailAccountType.ExchangeSharedMailBoxAccount)
            {
                // use shared mailbox to send email
                // create new email in draft folder from exchange server's shared mail box
                var draftsFolder = GetExchangeServerSharedDefaultDraftsFolder(senderEmailAddress, response);
                var draftsFolderItems = draftsFolder.Items;
                mail = draftsFolderItems.Add(Type.Missing);
            }
            else
            {
                // use local profile draft folder to send email
                var draftsFolder = GetDefaultDraftsFolder(response);
                var draftsFolderItems = draftsFolder.Items;
                mail = draftsFolderItems.Add(Type.Missing);
                mail.Account = null;

                if (senderEmailAccountType == SenderEmailAccountType.DelegateForEmailAccount)
                {
                    // Set "Sent as on behalf for" from default email account
                    mail.SentOnBehalfOf = FindDelegateAddressEntry(senderEmailAddress);
                }
                else if (senderEmailAccountType == SenderEmailAccountType.NonDefaultEmailAccount)
                {
                    // send from other non-default email account
                    mail.Account = RdoSession.Accounts[senderEmailAddress];
                }
                else if (senderEmailAccountType == SenderEmailAccountType.GoogleAppsEmailAccount)
                {
                    // send from Google Apps email account
                    mail.Account = RdoSession.Accounts[GetGoogleAppEmailAccountName(senderEmailAddress)];
                }

            }
            return mail;
        }
Ejemplo n.º 2
0
        internal bool SetToSenderEmailProfile(string senderEmailAddress, out SenderEmailAccountType senderEmailAccountType)
        {
            senderEmailAccountType = SenderEmailAccountType.NotFound;

            // check if sender email in current profile first
            var emailAccountType = ValidSenderEmailAddressInEmailProfile(senderEmailAddress);
            if (emailAccountType != SenderEmailAccountType.NotFound)
            {
                senderEmailAccountType = emailAccountType;
                return true;
            }

            bool profileSwitched = false;
            foreach (string profileName in RdoSession.Profiles)
            {
                if (RdoSession.ProfileName == profileName)
                    continue;
                try
                {
                    // switch to other email profile
                    ProfileName = profileName;

                    // logon to other profile
                    SessionLogon();

                    emailAccountType = ValidSenderEmailAddressInEmailProfile(senderEmailAddress);
                    if (emailAccountType == SenderEmailAccountType.NotFound)
                        continue;

                    profileSwitched = true;
                    senderEmailAccountType = emailAccountType;
                    break;
                }
                catch (Exception)
                {
                    // capture exception and do nothing if fail to switch to that profile
                    ProfileName = string.Empty;
                }
            }

            return profileSwitched;
        }