コード例 #1
0
        public void SendServerEmailWithNoAttachments()
        {
            _engine          = new AutomationEngineInstance(null);
            _sendServerEmail = new SendServerEmailCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string filePath         = Path.Combine(projectDirectory, @"Resources\");
            string subject          = "No Attachments";
            string email            = filePath + @"Download\" + $"{subject}.msg";

            _sendServerEmail.v_AccountName   = "NicolePersonalTest";
            _sendServerEmail.v_ToRecipients  = "*****@*****.**";
            _sendServerEmail.v_CCRecipients  = "";
            _sendServerEmail.v_BCCRecipients = "";
            _sendServerEmail.v_Subject       = subject;
            _sendServerEmail.v_Body          = "Test Body";
            _sendServerEmail.v_Attachments   = "";

            _sendServerEmail.RunCommand(_engine);

            var emailMessage = GetEmail(filePath, subject);

            Assert.True(File.Exists(email));

            DeleteEmail(emailMessage);
            File.Delete(email);
        }
コード例 #2
0
        public void SendServerEmailWithAttachment()
        {
            _engine          = new AutomationEngineInstance(null);
            _sendServerEmail = new SendServerEmailCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string filePath         = Path.Combine(projectDirectory, @"Resources\");
            string fileName         = "testFile.txt";
            string attachment       = Path.Combine(filePath, @"Download", fileName);
            string subject          = "One Attachment";
            string email            = filePath + @"Download\" + $"{subject}.msg";

            //Send Server email with no account name (gets default email account)
            _sendServerEmail.v_AccountName   = "";
            _sendServerEmail.v_ToRecipients  = "*****@*****.**";
            _sendServerEmail.v_CCRecipients  = "";
            _sendServerEmail.v_BCCRecipients = "";
            _sendServerEmail.v_Subject       = subject;
            _sendServerEmail.v_Body          = "Test Body";
            _sendServerEmail.v_Attachments   = filePath + @"Upload\" + fileName;

            _sendServerEmail.RunCommand(_engine);

            var emailMessage = GetEmail(filePath, subject);

            Assert.True(File.Exists(email));
            Assert.True(File.Exists(attachment));

            DeleteEmail(emailMessage);
            File.Delete(email);
            File.Delete(attachment);
        }
コード例 #3
0
        public async Task HandlesNonExistentRecipients()
        {
            _engine          = new AutomationEngineInstance(null);
            _sendServerEmail = new SendServerEmailCommand();

            _sendServerEmail.v_AccountName   = "";
            _sendServerEmail.v_ToRecipients  = "";
            _sendServerEmail.v_CCRecipients  = "";
            _sendServerEmail.v_BCCRecipients = "";
            _sendServerEmail.v_Subject       = "One BCC";
            _sendServerEmail.v_Body          = "Test Body";
            _sendServerEmail.v_Attachments   = "";

            await Assert.ThrowsAsync <NullReferenceException>(() => _sendServerEmail.RunCommand(_engine));
        }