Example #1
0
        private IUniversalRequestObject ConvertToMimeStreamWithAttachment(string mimefilename)
        {
            NotesMailProxy proxy = new NotesMailProxy(m_notesProxy);
            using (Email2Mime mailItem2Mime = new Email2Mime(proxy))
            using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream())
            using (MimeProxy mimeProxy = new MimeProxy(mimeStream))
            {
                Assert.IsNotNull(mimeStream);
                SaveStream(mimefilename, mimeStream);

                Email2Uro email2Uro = new Email2Uro(mimeProxy);
                Assert.IsNotNull(email2Uro);
                IUniversalRequestObject uro = email2Uro.Convert(RequestChannel.LotusNotes);
                Assert.IsNotNull(uro);

                //sender
                Assert.IsTrue(1 == uro.Source.Items.Count, "Should only be a single source item");
                Assert.AreEqual("*****@*****.**", uro.Source.Items[0].Content, "Mismatch in email emailAddress");
                Assert.AreEqual("DevBuild", uro.Source.Items[0].Properties[SMTPPropertyKeys.DisplayName], "Mismatch in email address");

                // recipients
                Assert.AreEqual(3, uro.Destination.Items.Count, "Expected 3 items as the Token are set by default on To/Ccc/Bcc");
                Assert.AreEqual(AddressType.To, uro.Destination.Items[0].Properties[SMTPItemPropertyKeys.AddressType], "Destination should be of AddressType: To");
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", uro.Destination.Items[0].Content, "Mismatch in email emailAddress");
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", uro.Destination.Items[0].Properties[SMTPPropertyKeys.DisplayName], "Mismatch in email emailAddress");
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", uro.Destination.Items[1].Content, "Mismatch in email emailAddress");
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", uro.Destination.Items[1].Properties[SMTPPropertyKeys.DisplayName], "Mismatch in email emailAddress");

                //attachments
                Assert.AreEqual(1, uro.Attachments.Count);
                Assert.AreEqual("test.doc", uro.Attachments[0].Name, "Mismatch in attachment name");
                Assert.AreEqual("application/msword; name=test.doc", uro.Attachments[0].ContentType, "Mismatch in attachment content type");

                Assert.IsTrue(0 < uro.Attachments[0].Data.Length, "Expected the attachments data length to be greater then zero");

                using (Stream str = uro.Attachments[0].Data.AsStream())
                {
                    Assert.IsTrue(0 < str.Length, "Expected to find a non-empty stream");
                }

                Assert.AreEqual("LotusNotes", uro.Destination.Properties[SMTPPropertyKeys.RequestChannel]);
                Assert.AreEqual("LotusNotes", uro.Source.Properties[SMTPPropertyKeys.RequestChannel]);

                return uro;
            }
        }
        public void TestGetEnumerator()
        {
            using (WsActivationContext wsac = new WsActivationContext())
            {
                CreateNotesProxy();
                Assert.IsNotNull(m_notesProxy);

                NotesProxy.Attachment proxyAttachment = new NotesProxy.AttachmentClass();
                proxyAttachment.SetDisplayName("test.doc");
                proxyAttachment.SetFileName(m_testPath + "test.doc");
                proxyAttachment.SetContentItemIndex(1);
                proxyAttachment.SetContentId("B61002A0-1A85-48a5-9A95-7F254EECECF1");
                m_notesProxy.AddAttachment(proxyAttachment);

                NotesMailProxy proxy = new NotesMailProxy(m_notesProxy);
                Assert.IsTrue(proxy.Attachments.IsReadOnly);

                System.Collections.IEnumerable enumerable = proxy.Attachments as System.Collections.IEnumerable;
                System.Collections.IEnumerator enumerator = enumerable.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    EmailAttachment attachment = enumerator.Current as EmailAttachment;
                    Assert.AreEqual("test.doc", attachment.DisplayName);
                    Assert.IsTrue(attachment.FileName.Contains("test.doc"));
                }
            }
        }
Example #3
0
        public void TestProxy()
        {
            using (WsActivationContext wsac = new WsActivationContext())
            {
                CreateNotesProxy();
                Assert.IsNotNull(m_notesProxy);

                string subject = "Plain text e-mail: This is a test mail";
                m_notesProxy.SetSubject(subject);
                m_notesProxy.SetSender("DevBuild<*****@*****.**>");
                m_notesProxy.SetResolvedRecipientsTypeToken("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F");
                m_notesProxy.SetPriority(NotesProxy.NotesMailPriority.Normal);
                string body = "We have a body that looks like something";
                m_notesProxy.SetBody(body);

                NotesProxy.Attachment proxyAttachment = new NotesProxy.AttachmentClass();
                proxyAttachment.SetDisplayName("test.doc");
                proxyAttachment.SetFileName(m_testPath + "test.doc");
                proxyAttachment.SetContentItemIndex(1);
                proxyAttachment.SetContentId("B61002A0-1A85-48a5-9A95-7F254EECECF1");
                m_notesProxy.AddAttachment(proxyAttachment);

                NotesMailProxy proxy = new NotesMailProxy(m_notesProxy);

                Assert.AreEqual(Workshare.Mime.Conversions.Priority.Normal, proxy.Priority);
                proxy.Priority = Workshare.Mime.Conversions.Priority.High;
                Assert.AreEqual(Workshare.Mime.Conversions.Priority.High, proxy.Priority);
                proxy.Priority = Workshare.Mime.Conversions.Priority.Normal;

                Assert.AreEqual("Plain text e-mail: This is a test mail", proxy.Subject);

                subject = "Let change the subject";
                proxy.Subject = subject;
                Assert.AreEqual(subject, m_notesProxy.GetSubject());

                Assert.AreEqual(body, proxy.FormattedBodyText);
                body = "The body has been changed";
                proxy.FormattedBodyText = body;
                Assert.AreEqual(body, proxy.FormattedBodyText);

                Assert.AreEqual("DevBuild", proxy.Sender.Name);
                Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress);

                EmailRecipient newSender = new EmailRecipient();
                newSender.Name = "phantom";
                newSender.EmailAddress = "*****@*****.**";

                proxy.Sender = newSender;

                Assert.AreEqual("phantom", proxy.Sender.Name);
                Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress);

                Assert.AreEqual(1, proxy.ToRecipients.Count);
                Assert.AreEqual(1, proxy.CcRecipients.Count);
                Assert.AreEqual(1, proxy.BccRecipients.Count);

                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.ToRecipients[0].Name);
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.ToRecipients[0].EmailAddress);

                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.CcRecipients[0].Name);
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.CcRecipients[0].EmailAddress);

                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.BccRecipients[0].Name);
                Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.BccRecipients[0].EmailAddress);
                
                // Lets test the recipient iterator as well
                foreach (IEmailRecipient recipient in proxy.ToRecipients)
                {
                    Assert.IsTrue(recipient.Name.Contains("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F"));
                }

                Assert.AreEqual(1, proxy.Attachments.Count);
                Assert.AreEqual("test.doc", proxy.Attachments[0].DisplayName);
                Assert.AreEqual("application/msword; name=test.doc", proxy.Attachments[0].ContentType);
                Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream");

                // Lets test the attachment iterator as well
                foreach (IEmailAttachment attachment in proxy.Attachments)
                {
                    Assert.IsTrue(attachment.DisplayName.Contains("test.doc"));
                }
            }
        }
Example #4
0
		internal PolicyContent.Request CreateRequest(IProxy mailItem)
		{
			NotesMailProxy proxy = new NotesMailProxy(mailItem);
			Email2Request email2Uro = new Email2Request(proxy);
			return email2Uro.Convert(RequestChannel.LotusNotes, false);
		}