private void LoadDocumentProperties(Redemption.Attachment _attachment) { try { if (_size > 0) // This is needed as 0 byte .doc files have no custom property storage. { Logger.LogInfo(string.Format("Loading .... {0}", _displayName)); string tempfile = Utils.GetTempFile(System.IO.Path.GetExtension(_fileName)); _attachment.SaveAsFile(tempfile); var idoc = new IntelligentDocument(); idoc.SetFileName(tempfile); if (idoc.IsDocumentBeingTracked()) { _checkSum = idoc.CalculateDocumentChecksum(); _trackingId = idoc.GetDocumentTrackingId(); _isModified = idoc.IsDocumentModified(); } else { // set the tracking id to an unique value to ensure that it isn't discovered during the // comparison stage _trackingId = Guid.NewGuid().ToString(); } Utils.SafeDeleteFile(tempfile); } } catch (System.Exception e) { Logger.LogError(e); } }
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; }