/// <summary>
        /// Handles the Click event of the MenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var        menuitem = sender as System.Windows.Controls.MenuItem;
            FileStream fs       = null;
            IMessage   response;

            try
            {
                switch (menuitem.Header.ToString().ToLower())
                {
                case "open":
                    var docId = ((menuitem.Parent as System.Windows.Controls.ContextMenu).PlacementTarget as System.Windows.Controls.Button).Tag.ToString();
                    response = ((IContactPlugin)Pointel.Interactions.IPlugins.PluginCollection.GetInstance().PluginCollections[Plugins.Contact]).GetDocument(docId);
                    if (response != null && response.Id == EventGetDocument.MessageId)
                    {
                        eventGetDocument = (EventGetDocument)response;
                        string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString() + @"\Pointel\temp\" + docId.ToString() + @"\"; logger.Info("Opening the file : " + eventGetDocument.TheName);
                        if (string.IsNullOrEmpty(Path.GetDirectoryName(eventGetDocument.TheName)))
                        {
                            eventGetDocument.TheName = path + @"\" + eventGetDocument.TheName;
                        }
                        logger.Info("Creating the file : " + eventGetDocument.TheName);
                        if (!Directory.Exists(Path.GetDirectoryName(eventGetDocument.TheName)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(eventGetDocument.TheName));
                        }
                        using (fs = new FileStream(eventGetDocument.TheName, FileMode.Create)) { }
                        File.WriteAllBytes(eventGetDocument.TheName, eventGetDocument.Content);
                        Process.Start(eventGetDocument.TheName);
                    }
                    break;

                case "save":
                    response = ((IContactPlugin)Pointel.Interactions.IPlugins.PluginCollection.GetInstance().PluginCollections[Plugins.Contact]).GetDocument(((menuitem.Parent as System.Windows.Controls.ContextMenu).PlacementTarget as System.Windows.Controls.Button).Tag.ToString());
                    if (response != null && response.Id == EventGetDocument.MessageId)
                    {
                        eventGetDocument = (EventGetDocument)response;
                        SaveFileDialog saveDialog = new SaveFileDialog();
                        saveDialog.FileName = eventGetDocument.TheName;
                        string _fileExtension = System.IO.Path.GetExtension(eventGetDocument.TheName);
                        saveDialog.FileOk      += new CancelEventHandler(saveFileDialog_FileOk);
                        saveDialog.DefaultExt   = "." + _fileExtension;
                        saveDialog.Filter       = "All files (*.*) | *.*";
                        saveDialog.AddExtension = true;
                        saveDialog.ShowDialog();
                    }
                    break;
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while " + menuitem.Header.ToString().ToLower() + " the attachment '" + menuitem.Header.ToString().Trim() + "'  as :" + generalException.ToString());
            }
        }
 /// <summary>
 /// Handles the FileOk event of the saveFileDialog control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="CancelEventArgs"/> instance containing the event data.</param>
 private void saveFileDialog_FileOk(object sender, CancelEventArgs e)
 {
     try
     {
         string fileName = (sender as SaveFileDialog).FileName;
         if (eventGetDocument != null)
         {
             File.WriteAllBytes((string.IsNullOrEmpty(fileName) ? (eventGetDocument.TheName + (eventGetDocument.TheName.EndsWith(_fileExtension) ? "" : _fileExtension)) : fileName), eventGetDocument.Content);
             eventGetDocument = null;
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error occurred while save File Dialog as : " + ex.Message);
     }
 }
 private void UserControl_Unloaded(object sender, RoutedEventArgs e)
 {
     _fileExtension   = string.Empty;
     eventGetDocument = null;
     htmlEditor       = null;
 }