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 TestRecipientAddressInX400Format() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Test outlook proxy: TestRecipientAddressInX400Format"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "BlackHole<*****@*****.**>"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string rtfBody = "We have a body that looks like something"; outlookEmailWrapper.Body = rtfBody; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) using (Email2Mime mailItem2Mime = new Email2Mime(proxy)) using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream()) using (MimeProxy mimeProxy = new MimeProxy(mimeStream)) { Email2Request email2Request = new Email2Request(mimeProxy); Request request = email2Request.Convert(RequestChannel.Outlook, false); outlookEmailWrapper.MailItem.Delete(); // Now fake an X400 email address Workshare.PolicyContent.RoutingItem routingItem = request.Destination.Items[0]; Workshare.PolicyContent.RoutingItem modifiedRoutingItem = new Workshare.PolicyContent.RoutingItem(); modifiedRoutingItem.Content = "/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole"; System.Collections.Generic.List< CustomProperty> custProps = new System.Collections.Generic.List<CustomProperty>(); foreach (CustomProperty prop in routingItem.Properties) { custProps.Add(prop); } custProps.Add(new CustomProperty(EmailProperties.ReadOnlyKey, bool.TrueString)); modifiedRoutingItem.Properties = custProps.ToArray(); request.Destination.Items = new Workshare.PolicyContent.RoutingItem[] { modifiedRoutingItem }; // Now do a convert again with the modified uro email2Request.Convert(RequestChannel.Outlook, request, false); Assert.AreEqual(1, request.Destination.Items.Length); routingItem = request.Destination.Items[0]; Assert.AreEqual("/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole", routingItem.Content); Assert.AreEqual("BlackHole", GetPropertyValue(SMTPItemPropertyKeys.DisplayName, routingItem.Properties)); Assert.AreEqual(AddressType.To, GetPropertyValue(SMTPItemPropertyKeys.AddressType, routingItem.Properties)); Assert.AreEqual(bool.TrueString, GetPropertyValue(EmailProperties.ReadOnlyKey, routingItem.Properties)); } } }
public void TestRoundTripDropAttachments() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Test outlook proxy: TestRoundTripDropAttachments"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.CcRecipients = "*****@*****.**"; outlookEmailWrapper.BccRecipients = "[email protected];[email protected]"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string rtfBody = "We have a body that looks like something"; outlookEmailWrapper.Body = rtfBody; outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "Mickey Mouse", Outlook.OlAttachmentType.olByValue); outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.AreEqual(1, proxy.Attachments.Count); // DE9310, requires to change this test behavior Assert.AreEqual("Mickey Mouse", proxy.Attachments[0].DisplayName); Assert.AreEqual("application/msword; name=Mickey Mouse", proxy.Attachments[0].ContentType); Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream"); // Lets convert the outlook mail message to MIME using (Email2Mime mailItem2Mime = new Email2Mime(proxy)) using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream()) using (MimeProxy mimeProxy = new MimeProxy(mimeStream)) { // Drop the attachments in the MIME stream mimeProxy.Attachments.Clear(); Email2Request email2Request = new Email2Request(mimeProxy); Request request = email2Request.Convert(RequestChannel.Outlook, false); outlookEmailWrapper.MailItem.Delete(); Assert.AreEqual(0, request.Attachments.Length); // Synchronise the email with the changes made to the URO //Assert.AreEqual(0, proxy.Attachments.Count); } } } }
public Stream ExecuteMime(IActionData3 data, ActionPropertySet aProperties) { if (aProperties.SystemProperties.ContainsKey(SystemPropertiesStringTable.SysProp_FileType)) { if (!SupportedFileCollection.Supports(aProperties.SystemProperties[SystemPropertiesStringTable.SysProp_FileType].Value as string)) { Logger.LogError(Properties.Resources.UNABLE_TO_TAG_NON_SUPPORTED_FILETYPE); return null; } } if ((bool) aProperties[RPostActionStringTable.SendRegistered].Value == false) { return data.Content; } MimeProxy mime = new MimeProxy(data.Content); foreach (IEmailRecipient recipient in mime.ToRecipients) recipient.EmailAddress = recipient.EmailAddress + ".workshare.rpost.org"; foreach (IEmailRecipient recipient in mime.CcRecipients) recipient.EmailAddress = recipient.EmailAddress + ".workshare.rpost.org"; foreach (IEmailRecipient recipient in mime.BccRecipients) recipient.EmailAddress = recipient.EmailAddress + ".workshare.rpost.org"; if ((bool) aProperties[RPostActionStringTable.Unmarked].Value == true) { string subject = mime.Subject; mime.Subject = "(C) " + subject; } Email2Mime email = new Email2Mime(mime); return email.ConvertToMimeStream(); }