private Attachment GetAttachment(Redemption.Attachment redemptionAttachment, int bodyFormat) { string temp = LocalFileManager.GetLocalCopyOfFileTarget(redemptionAttachment.DisplayName); DeleteFile(temp); redemptionAttachment.SaveAsFile(temp); _unpackedTempCopies.Add(temp); // Attachment Content Type cannot be determined, whilst the Index will be set at a // higher level -> Flatten call // [09/07/09] DE9310 DZ: Prefer using FileName instead of DisplayName due for // this defect. // [01/09/09] DE9621 DZ: Redemption.Attachment.FileName/DisplayName couldn't correctly retrieve // the Unicode names when running on Office2003 with "Cached Exchanged Mode" turned on. Therefore // try raw attribute first. // RightClick send .msg, PR_ATTACH_LONG_FILENAME_W/PR_DISPLAY_NAME_W donot present. // Drag to attach .msg and send, PR_ATTACH_LONG_FILENAME_W does not present. string attname = redemptionAttachment.get_Fields(MapiDefines.PR_ATTACH_LONG_FILENAME_W) as string; if (string.IsNullOrEmpty(attname)) { attname = redemptionAttachment.get_Fields(MapiDefines.PR_DISPLAY_NAME_W) as string; if (string.IsNullOrEmpty(attname)) { // Redemption.Attachment.FileName should never return null/contain invalid file name characters // but can incorrectly decode Unicode characters, resulting underscores '____'. attname = redemptionAttachment.FileName; } } // Sanitize required due to filename retrieved from "get_fields()" may contain "????" for incorrectly // decoded Unicode character. attname = LocalCopyOfFileManager.GetValidFileName_excl_invalid_chars(attname); var attachment = new Attachment(new FCS.Lite.Interface.File(temp, attname), string.Empty, Guid.NewGuid().ToString(), string.Empty, false) { Properties = new[] { new CustomProperty(PropertyNames.LocalFileName, temp) } }; using (RWSAttachment rWSAttachment = new RWSAttachment(redemptionAttachment)) { attachment.IsSignature = MapiSignatureInspector.IsSignature(rWSAttachment, (OlBodyFormat)bodyFormat); } return attachment; }
private void RemoveReadyRedlineCategory(Redemption.SafeMailItem mailItem) { object[] categories = (object[]) mailItem.get_Fields(MapiDefines.PR_CATEGORIES); if (categories != null) { // Copy over all the categories except for ReadyRedline List<object> cleanedCategories = new List<object> { "" }; // Need at least an empty entry cleanedCategories.AddRange((from string s in categories where String.CompareOrdinal(s, OptionApi.GetString("ReadyRedlineCategoryName")) != 0 select s)); // Replace the categories mailItem.set_Fields(MapiDefines.PR_CATEGORIES, cleanedCategories.ToArray()); } }