Esempio n. 1
0
        public void TestUpdateSubjectOnMessageWithNoMessageWideCharacterSet()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string script = "Sub OnAcceptMessage(oClient, oMessage) " + Environment.NewLine +
                            " oMessage.Subject = \"[ov]\" + oMessage.Subject " + Environment.NewLine +
                            " oMessage.Save() " + Environment.NewLine +
                            "End Sub" + Environment.NewLine + Environment.NewLine;

            hMailServer.Scripting scripting = _settings.Scripting;
            System.IO.File.WriteAllText(scripting.CurrentScriptFile, script);
            scripting.Enabled = true;
            scripting.Reload();
            Assert.IsEmpty(scripting.CheckSyntax());

            string body = @"From: <*****@*****.**>" + Environment.NewLine +
                          "Subject: =?windows-1251?B?yuDr7Pvq7uLzIMji4O3zIC0g7/Do7OXwICLy5fXt6Pfl8eru4+4g8OX4?=" + Environment.NewLine +
                          "   =?windows-1251?B?5e3o/yIgW0Z3ZDog0tAg4uXw8ejoIDEuMl0=?=" + Environment.NewLine +
                          Environment.NewLine +
                          "Hej!" + Environment.NewLine;



            SMTPClientSimulator.StaticSendRaw("*****@*****.**", "*****@*****.**", body);

            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            string subject = account.IMAPFolders[0].Messages[0].Subject;
        }
Esempio n. 2
0
        private void buttonCheckSyntax_Click(object sender, EventArgs e)
        {
            string result = _scriptingSettings.CheckSyntax();

            MessageBoxIcon icon = MessageBoxIcon.Error;

            if (result.Length == 0)
            {
                result = "The syntax is correct.";
                icon   = MessageBoxIcon.Information;
            }

            MessageBox.Show(result, EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, icon);
        }
Esempio n. 3
0
        public void TestAddTextDuringSending()
        {
            hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to the account.
            hMailServer.Message oMessage = new hMailServer.Message();
            Assert.AreEqual(0, oMessage.State);

            hMailServer.Scripting scripting = SingletonProvider <Utilities> .Instance.GetApp().Settings.Scripting;

            string signature = "MySignature";

            string script = "Sub OnAcceptMessage(oClient, oMessage) " + Environment.NewLine +
                            " Call EventLog.Write(\"Subject:\" +oMessage.Subject)" + Environment.NewLine +
                            " Call EventLog.Write(\"Date:\" +oMessage.Date)" + Environment.NewLine +
                            " Call EventLog.Write(\"Body:\" +oMessage.Body)" + Environment.NewLine +
                            " oMessage.Body = oMessage.Body & \"" + signature + "\" " + Environment.NewLine +
                            " oMessage.Save() " + Environment.NewLine +
                            "End Sub" + Environment.NewLine + Environment.NewLine;

            System.IO.File.WriteAllText(scripting.CurrentScriptFile, script);
            scripting.Enabled = true;
            scripting.Reload();
            Assert.IsEmpty(scripting.CheckSyntax());

            // Send the message.
            List <string> recipients = new List <string>();

            recipients.Add("*****@*****.**");
            SMTPClientSimulator.StaticSend("*****@*****.**", recipients, "Hej", "Välkommen till verkligheten");

            // Check that the message exists
            string message = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test");

            Assert.IsNotEmpty(message);
            Assert.IsTrue(message.Contains(signature));
            Assert.Less(0, message.IndexOf("Hej"));
        }