Exemple #1
0
        public IEmailProvider GetProvider(EmailMessage email)
        {
            IEmailProvider retVal = null;


            EmailConnection connection = email.GetConnection();

            if (connection != null)
            {
                if (this.Providers.ContainsKey(connection.Name))
                {
                    //get cached data command provider
                    retVal = this.Providers[connection.Name];
                }
                else
                {
                    EmailConnectionType connectionType = connection.GetConnectionType();

                    if (connectionType != null)
                    {
                        string assemblyName = connectionType.Assembly;
                        string className    = connectionType.Class;

                        if (!String.IsNullOrEmpty(assemblyName) && !String.IsNullOrEmpty(className))
                        {
                            try
                            {
                                Assembly providerAssembly = Assembly.Load(assemblyName);
                                if (providerAssembly != null)
                                {
                                    Type type = providerAssembly.GetType(className, true, true);

                                    if (type != null)
                                    {
                                        ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
                                        retVal = constructor.Invoke(null) as IEmailProvider;

                                        retVal.Initialize(connectionType.Settings);

                                        this.Providers.Add(connection.Name, retVal);
                                    }
                                }
                            }
                            catch
                            {
                                //silent error
                            }
                        }
                    }
                }
            }

            if (retVal == null)
            {
                throw new Exception(String.Format("No valid email provider was found"));
            }

            return(retVal);
        }
Exemple #2
0
        private void SaveEmailConnection()
        {
            EmailConnection item = new EmailConnection();

            item.Name = ItemName.Text;

            Configuration.GetInstance().EmailConnections.Add(item);
            EmailConnection.Save(item);
        }
Exemple #3
0
 /// <summary>
 /// Select a mailbox by name
 /// </summary>
 /// <param name="mailbox">The name of the mailbox</param>
 /// <example>
 /// <code source="../EmailUnitTests/EmailUnitWithDriver.cs" region="SelectMailbox" lang="C#" />
 /// </example>
 public virtual void SelectMailbox(string mailbox)
 {
     GenericWait.WaitFor <bool>(() =>
     {
         CurrentMailBox = mailbox;
         CurrentFolder  = EmailConnection.GetFolder(mailbox);
         CurrentFolder.Open(FolderAccess.ReadWrite);
         return(true);
     });
 }
Exemple #4
0
 /// <summary>
 /// Get a mailbox by name
 /// </summary>
 /// <param name="mailbox">The mailbox name</param>
 /// <returns>The mailbox</returns>
 /// <example>
 /// <code source="../EmailUnitTests/EmailUnitWithDriver.cs" region="GetMailbox" lang="C#" />
 /// </example>
 public virtual IMailFolder GetMailbox(string mailbox)
 {
     return(GenericWait.WaitFor <IMailFolder>(() =>
     {
         CurrentMailBox = mailbox;
         CurrentFolder = EmailConnection.GetFolder(mailbox);
         CurrentFolder.Open(FolderAccess.ReadWrite);
         return CurrentFolder;
     }));
 }
Exemple #5
0
        /// <summary>
        /// Get the list of mailbox names in a specific namespace
        /// </summary>
        /// /// <param name="folderNamespace">The folderNamespace</param>
        /// <returns>A list of mailbox names in a specific namespace</returns>
        public virtual List <string> GetMailBoxNamesInNamespace(FolderNamespace folderNamespace)
        {
            return(GenericWait.WaitFor <List <string> >(() =>
            {
                List <string> mailBoxes = new List <string>();

                // Get all mailboxes in folderNamespace
                foreach (IMailFolder mailbox in EmailConnection.GetFolders(folderNamespace))
                {
                    mailBoxes.Add(mailbox.FullName);
                }

                return mailBoxes;
            }));
        }
        public List <object> GetItems(string folder, string name)
        {
            List <object> retVal = new List <object>();

            if (String.IsNullOrEmpty(name))
            {
                retVal = new List <object>(Configuration.GetInstance().EmailConnections.Cast <object>());
            }
            else
            {
                retVal.Add(EmailConnection.GetByName(name));
            }

            return(retVal);
        }
Exemple #7
0
 public EmailService(IOptions <EmailConnection> options)
 {
     slumpisOptions = options.Value;
 }
 public void Save(object configurationItem)
 {
     EmailConnection.Save((EmailConnection)configurationItem);
 }
 public int GetCounts(string folder, string name)
 {
     return(EmailConnection.GetItemCount(name));
 }
 public void Load(XDocument doc, string folder)
 {
     EmailConnection.Load(doc);
 }