コード例 #1
0
ファイル: MailAttachment.cs プロジェクト: killbug2004/WSProf
        public MailAttachment(Redemption.Attachment attachment, string mailitemEntryId, int attachmentIndex)
        {
			_attachmentIndex = attachmentIndex;
			_entryId = mailitemEntryId;
            _fileName = attachment.FileName;
            _displayName = attachment.DisplayName;
            _size = attachment.FileSize;
			LoadDocumentProperties(attachment);
        }
コード例 #2
0
ファイル: RWSAddressEntry.cs プロジェクト: killbug2004/WSProf
        internal RWSAddressEntry(Redemption.AddressEntry ae)
        {
            m_ae = ae;
			// force Redemption to synchronize with underlying Outlook object model. 
			// fixes empty sender address issue on Outlook 2013 + Exchange 2007 Cached mode
	        object mapiObject = m_ae.MAPIOBJECT;
            if (mapiObject != null && Marshal.IsComObject(mapiObject))
			{
                Marshal.ReleaseComObject(mapiObject);
			}
        }
コード例 #3
0
ファイル: MailAttachment.cs プロジェクト: killbug2004/WSProf
		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);
            }
        }
コード例 #4
0
ファイル: RWSMessageItem.cs プロジェクト: killbug2004/WSProf
 internal RWSMessageItem(Redemption.MessageItem msg)
 {
     m_msg = msg;
 }
コード例 #5
0
ファイル: RWSUtilities.cs プロジェクト: killbug2004/WSProf
		static private void ProcessGroup(Redemption.AddressEntries addressEntries, List<string> lRecipients)
		{
			foreach (Redemption.AddressEntry entry in addressEntries)
			{
				try
				{
					if (entry.Members != null)
						ProcessGroup((Redemption.AddressEntries) entry.Members, lRecipients);
					else
						AddMemberToList(entry.Name, lRecipients);
				}
				catch (Exception ex)
				{
					Logger.LogError(ex);
					if (entry != null)
						AddMemberToList(entry.Name, lRecipients);
				}
			}
		}
コード例 #6
0
		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;
		}
コード例 #7
0
		private string[] RemoveAllAttachmentsFromMSGPreserveSignature(Redemption.SafeMailItem msgItem, OlBodyFormat format)
		{
            var recordKeys = new List<string>();
			Redemption.Attachments attachments = msgItem.Attachments;
			using (new ComRelease(attachments))
			{
				for (int i = attachments.Count; i > 0; i--)
				{
					Redemption.Attachment attachment = attachments.Item(i);
					using (var rwsAttachment = new RWSAttachment(attachment))
					{
						if (!MapiSignatureInspector.IsSignature(rwsAttachment, format))
						{
                            try
                            {
                                object data = attachment.get_Fields(MapiDefines.PR_RECORD_KEY);
                                if (data != null)
                                {
                                    string recordkey = GetStringFromBytes(data);
                                    recordKeys.Add(recordkey);
                                }
                            }
                            catch(Exception ex)
                            {
                                Interop.Logging.Logger.LogError(ex);
                            }                            
							attachment.Delete();
						}
					}
				}
			}
            return recordKeys.ToArray();
		}
コード例 #8
0
ファイル: RWSCurrentUser.cs プロジェクト: killbug2004/WSProf
 public RWSCurrentUser(Redemption.SafeCurrentUser cu)
 {
     m_cu = cu;
 }
コード例 #9
0
		private void GetAttachmentProperties(Redemption.SafeMailItem rdMail, Dictionary<string, AttachmentProperties> dictAttachmentProps)
		{
			foreach (Redemption.Attachment att in rdMail.Attachments)
			{
				if (att.Type == (int) OlAttachmentType.olOLE)
				{
					// OLE attachments are currently not processed like the rest
					// (removed, processed, then added back to the mail item)
					continue;
				}

				object data = att.get_Fields(MapiDefines.PR_RECORD_KEY);
				if (data == null)
				{
					continue;	// no record key, so we can't add it to the dictionary
				}
				string recordkey = GetStringFromBytes(data);
				if (dictAttachmentProps.ContainsKey(recordkey))
				{
					// If the same doc is attached more than once use the same props.
					// TODO: this doesn't cover the case where different files are attached
					// but they have the same name and one is embedded while the other is attached.
					continue;
				}

				AttachmentProperties attProps = new AttachmentProperties();
				attProps.OContentId = att.get_Fields(MapiDefines.PR_ATTACH_CONTENT_ID);
				attProps.OHidden = att.get_Fields(MapiDefines.PR_ATTACHMENT_HIDDEN);
				attProps.OFlags = att.get_Fields(MapiDefines.PR_ATTACHMENT_FLAGS);
				attProps.OPosition = att.get_Fields(MapiDefines.PR_RENDERING_POSITION);
				attProps.OContactPhoto = att.get_Fields(0x7FFF000B);//contact photo    

                data = att.get_Fields(MapiDefines.PR_CREATION_TIME);
				if (data != null)
				{
					attProps.CreationTime = (DateTime) data;
				}
				else
				{
					attProps.CreationTime = DateTime.Now;
				}

				data = att.get_Fields(MapiDefines.PR_LAST_MODIFICATION_TIME);
				if (data != null)
				{
					attProps.LastModifiedtime = (DateTime) data;
				}
				else
				{
					attProps.LastModifiedtime = System.DateTime.Now;
				}

				dictAttachmentProps.Add(recordkey, attProps);
			}
		}
コード例 #10
0
		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());
			}
		}
コード例 #11
0
		/// <summary>
		/// Use seperate function to handle embedded message attachment, as 
		/// Redemption.Attachment.SaveAsFile will incorrectly save Unicode subject line and
		/// Unicode attachment file name into Ansi.
		/// </summary>
		/// <param name="embeddeditem"></param>
		/// <returns></returns>
		private Attachment GetAttachment(Redemption.MessageItem embeddeditem)
		{
			using (new ComRelease(embeddeditem))
			{
				string temp = LocalFileManager.GetLocalCopyOfFileTarget(embeddeditem.Subject);
				DeleteFile(temp);

				temp = Path.ChangeExtension(temp, MsgExtension);

				embeddeditem.SaveAs(temp, OlSaveAsType.olMSGUnicode);
				_unpackedTempCopies.Add(temp);

				// Use the subject field as the attachment name for embedded items.
				// NB this does NOT have a file extension, and this code should be kept
				// in line with that used to add attachments via the object model
				// for Office 2010 - see OOMWSMailAttachmentTransform.
				string attname = embeddeditem.Subject;

				attname = LocalCopyOfFileManager.GetValidFileName_excl_invalid_chars(attname);
				if (string.IsNullOrEmpty(attname) || string.IsNullOrEmpty(attname.Trim()))
				{
					attname = UntitledAttachmentTitle;
				}

				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) }
											};
				return attachment;
			}
		}
コード例 #12
0
ファイル: RWSAttachment.cs プロジェクト: killbug2004/WSProf
 internal RWSAttachment(Redemption.Attachment attachment)
 {
     m_attachment = attachment;
 }
コード例 #13
0
ファイル: RWSRecipient.cs プロジェクト: killbug2004/WSProf
 internal RWSRecipient(Redemption.SafeRecipient recipient)
 {
     m_recipient = recipient;
 }
コード例 #14
0
ファイル: NewGetMembers.cs プロジェクト: killbug2004/WSProf
		/// <summary>
		/// This method will process the mail group to extract the individual mail 
		/// accounts out and then add these.  It will call itself if the there are
		/// embedded mail groups.
		/// </summary>
		/// <param name="members">The members to process</param>
		private void ProcessGroup( Redemption.AddressEntries members )
		{			
			foreach( Redemption.AddressEntry entry in members )
			{
				if ( entry.Members != null )
					ProcessGroup((Redemption.AddressEntries) entry.Members );
				else
					AddMemberToList( entry.Name );
			}
		}
コード例 #15
0
ファイル: RWSAttachments.cs プロジェクト: killbug2004/WSProf
 internal RWSAttachments(Redemption.Attachments attachments)
 {
     m_attachments = attachments;
 }
コード例 #16
0
		private Redemption.RDOAddressList FindAddressList(Redemption.RDOAddressLists als, string alname)
		{
            try
            {
			    foreach (Redemption.RDOAddressList al in als)
			    {
				    if (al.Name == alname)
				    {
					    return al;
				    }
			    }
            }
            catch (Exception ex)
            {
                Workshare.Interop.Logging.Logger.LogError(ex);
            }
			return null;
		}
コード例 #17
0
		private Redemption.RDOAddressEntry FindAddressEntry(Redemption.IRDOAddressEntries entries, string aename)
		{
            try
            {
                foreach (Redemption.RDOAddressEntry ae in entries)
                {
                    if (ae.Name == aename)
                    {
                        return ae;
                    }
                }
            }
            catch (Exception ex)
            {
                Workshare.Interop.Logging.Logger.LogError(ex);
            }
			return null;
		}
コード例 #18
0
		private void AddAttachmentToMSG(Workshare.PolicyContent.Attachment attachment, Redemption.SafeMailItem msg, int index, bool isAnEmbeddedEmail)
		{
			string fileName = string.Empty;
			Redemption.MAPIUtils rdMAPIUtils = RedemptionLoader.new_MAPIUtils();

			try
			{
				// A subject line like 
				// "test messed up subject line, invalid characters: /\/\ 29/04/2004\"
				// in an email is why LocalCopyOfFileManager.GetValidFileName() cant be used
				//
				// Change to replace invalid characters by underscore to avoid potential empty file name. e.g. '   .msg'
				fileName = attachment.FileName;

				if (isAnEmbeddedEmail)
					fileName = Path.ChangeExtension(fileName, MsgExtension);

				Redemption.Attachments attachments = msg.Attachments;

				using (new ComRelease(attachments))
				{
					if (isAnEmbeddedEmail)
					{
						// Embedded msg can be added correctly with Unicode subject / filename
						Redemption.MessageItem msgitem = rdMAPIUtils.GetItemFromMsgFile(fileName, false);
						using (new ComRelease(msgitem))
						{
							Redemption.Attachment newAttach = attachments.Add(msgitem,
														 OlAttachmentType.olEmbeddeditem,
														 index,
														 attachment.Name);
							string displayname = msgitem.Subject;
							using (new ComRelease(newAttach))
							{
								if (string.IsNullOrEmpty(displayname) || string.IsNullOrEmpty(displayname.Trim()))
								{
									newAttach.set_Fields(MapiDefines.PR_DISPLAY_NAME_W, UntitledAttachmentTitle);
								}
								else
								{
									newAttach.set_Fields(MapiDefines.PR_DISPLAY_NAME_W, msgitem.Subject);
								}
							}
						}
					}
					else
					{
						Redemption.Attachment newAttach = attachments.Add(fileName,
													 OlAttachmentType.olByValue,
													 index,
													 attachment.Name);
						using (new ComRelease(newAttach))
						{
							// Redemption.Attachments.Add() doesnt handle Unicode Filename/DisplayName correctly, 
							// so have to manually set Filename/Display afterwards
							Encoding ae = Encoding.GetEncoding(Encoding.Default.CodePage, new EncoderExceptionFallback(), new DecoderExceptionFallback());
							try
							{
								byte[] ansiBytes = ae.GetBytes(fileName);
							}
							catch (EncoderFallbackException /*ex*/)
							{
								// If cannot converted using current system codepage, Redemption's Attachments.add() 
								// will not behave correctly. Have to manually set the FileName and Displayname with Unicode string.
								newAttach.set_Fields(MapiDefines.PR_ATTACH_LONG_FILENAME_W, attachment.Name);
								newAttach.set_Fields(MapiDefines.PR_ATTACH_FILENAME_W, attachment.Name);
								newAttach.set_Fields(MapiDefines.PR_DISPLAY_NAME_W, attachment.Name);
							}
						}
					}
				}

			}
			finally
			{
				if (rdMAPIUtils != null)
				{
					rdMAPIUtils.Cleanup();

                    if (Marshal.IsComObject(rdMAPIUtils))
                    {
					    Marshal.ReleaseComObject(rdMAPIUtils);
                    }
				}
			}
		}