Esempio n. 1
0
File: Tools.cs Progetto: KeeeM/OE7
        public static Hashtable GetAttachments(outlook.MailItem mail)
        {
            /*

             * Gets the attachments of selected mail of outlook mail items.
               :Param outlook.MailItem mail : gives the selected mail item from the outlook.
             * returns the hashtable (dictionary) value of the attachemts.
             */
            System.IO.FileStream inFile;
            Hashtable attach = new Hashtable();
            string[] strattch = new string[4];
            foreach (outlook.Attachment attach1 in mail.Attachments)
            {
                string filename = Tools.GetAppFolderPath() + attach1.FileName;
                attach1.SaveAsFile(filename);
                inFile = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                byte[] datas = new Byte[inFile.Length];
                long bytesRead = inFile.Read(datas, 0, (int)inFile.Length);
                inFile.Close();
                string fdata = System.Convert.ToBase64String(datas);
                attach.Add(attach1.FileName, fdata);
                strattch[0] = attach1.FileName;
                System.IO.File.Delete(filename);
            }
            return attach;
        }
Esempio n. 2
0
        private void Inspectors_NewInspector(Outlook.Inspector Inspector)
        {
            Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;

            Outlook.Links links = mailItem.Links;
            
            Outlook.Recipients recipients = mailItem.Recipients;
            
            String body = mailItem.HTMLBody;

            //Regex to Match the URL String that is read from the Body.
            //as given on http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without. 
            var matches = Regex.Matches(body, @"<a\shref=""((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)</a>");
            foreach (Match match in matches)
            {
                System.Windows.Forms.MessageBox.Show(match.Value);
            }

            if (mailItem != null)
            {
                if (mailItem.EntryID == null)
                {
                    mailItem.Subject = "This text was added by using code";
                    mailItem.Body = "This text was added by using code";
                }

            }
        }
Esempio n. 3
0
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="Inspector"></param>
 public InspectorWrapper(Outlook.Inspector Inspector)
 {
     inspector = Inspector;
     ((Outlook.InspectorEvents_Event)inspector).Close += new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);
     taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new EmailTreeControll(), "for Wylie", inspector);
     taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);
 }
Esempio n. 4
0
        // 返回出现在 RSS 项的标题中的“View article”链接的 URL。
        public static string ParseUrl(Outlook.PostItem item)
        {
            const string lookUpText = "HYPERLINK";
            const string articleStr = "View article";
            string body = item.Body;

            int index = body.IndexOf(lookUpText, 0, body.Length);
            int end = 0;
            // 在正文中查找“HYPERLINKS”并将范围缩小到“View article...”链接。
            while (true)
            {
                end = body.IndexOf(articleStr, index, body.Length - index);
                int nextIndex = body.IndexOf(lookUpText, index + 1, body.Length - (index + 1));

                if (nextIndex > index && nextIndex < end)
                {
                    index = nextIndex;
                }
                else
                    break;
            }
            // 获取文章的链接。
            string url = body.Substring(index + lookUpText.Length + 1, end - index - (lookUpText.Length + 1));

            url = url.Trim('"');

            return url;
        }
 public static DateTime? GetOutlookLastSync(Synchronizer sync, Outlook.ContactItem outlookContact)
 {
     DateTime? result = null;
     Outlook.UserProperties userProperties = outlookContact.UserProperties;
     try
     {
         Outlook.UserProperty prop = userProperties[sync.OutlookPropertyNameSynced];
         if (prop != null)
         {
             try
             {
                 result = (DateTime)prop.Value;
             }
             finally
             {
                 Marshal.ReleaseComObject(prop);
             }
         }
     }
     finally
     {
         Marshal.ReleaseComObject(userProperties);
     }
     return result;
 }
Esempio n. 6
0
        public MailMsg(Outlook.MailItem msg, string user)
        {
            this._User = user;
            this._id = msg.EntryID;
            timestamp = msg.SentOn;
            this._Subject = msg.Subject;
            this._Body = msg.Body;

            if (msg.Attachments.Count>0)
            {
                //we will add all attachements to a list
                List<Attachement> oList = new List<Attachement>();
                foreach (Outlook.Attachment att in msg.Attachments)
                {
                    //need to save file temporary to get contents
                    string filename = System.IO.Path.GetTempFileName();
                    att.SaveAsFile(filename);
                    System.IO.FileStream fs=new System.IO.FileStream(filename,System.IO.FileMode.Open);
                    oList.Add(new Attachement(fs, att.FileName));
                    fs.Close();
                    System.IO.File.Delete(filename);
                }
                this._Attachements = oList.ToArray();
                this.attList.AddRange(oList);
            }
        }
 public static string GetOutlookGoogleContactId(Synchronizer sync, Outlook.ContactItem outlookContact)
 {
     string id = null;
     Outlook.UserProperties userProperties = outlookContact.UserProperties;
     try
     {
         Outlook.UserProperty idProp = userProperties[sync.OutlookPropertyNameId];
         if (idProp != null)
         {
             try
             {
                 id = (string)idProp.Value;
                 if (id == null)
                     throw new Exception();
             }
             finally
             {
                 Marshal.ReleaseComObject(idProp);
             }
         }
     }
     finally
     {
         Marshal.ReleaseComObject(userProperties);
     }
     return id;
 }
        public void init(Outlook.Attachment attach)
        {
            attachment = attach;
                System.IO.FileInfo fi = new System.IO.FileInfo(attachment.FileName);
                lNom.Text = "Nom : " + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length);
                lType.Text = "Type : " + fi.Extension.ToString();
                lTaille.Text = "Taille : " + attachment.Size + " o";

                IDictionary<string, string> parameters = new Dictionary<string, string>();
                parameters[SessionParameter.BindingType] = BindingType.AtomPub;

                XmlNode rootNode = Config1.xmlRootNode();

                parameters[SessionParameter.AtomPubUrl] = rootNode.ChildNodes.Item(0).InnerText + "atom/cmis";
                parameters[SessionParameter.User] = rootNode.ChildNodes.Item(1).InnerText;
                parameters[SessionParameter.Password] = rootNode.ChildNodes.Item(2).InnerText;

                SessionFactory factory = SessionFactory.NewInstance();
                ISession session = factory.GetRepositories(parameters)[0].CreateSession();

                // construction de l'arborescence
                string id = null;
                IItemEnumerable<IQueryResult> qr = session.Query("SELECT * from cmis:folder where cmis:name = 'Default domain'", false);

                foreach (IQueryResult hit in qr) { id = hit["cmis:objectId"].FirstValue.ToString(); }
                IFolder doc = session.GetObject(id) as IFolder;

                TreeNode root = treeView.Nodes.Add(doc.Id, doc.Name);
                AddVirtualNode(root);
        }
Esempio n. 9
0
    // Uses recursion to enumerate Outlook subfolders.
    private void EnumerateFolders(Outlook.MAPIFolder folder, ICollection<Folder> folders )
    {
      var childFolders = folder.Folders;
      if (childFolders.Count == 0)
      {
        return;
      }

      foreach (Outlook.MAPIFolder item in childFolders)
      {
        // if this is not a mail item then we are not interested.
        // things like calendars and so on.
        if (item.DefaultItemType != Outlook.OlItemType.olMailItem)
        {
          continue;
        }

        // child folder item
        var childFolder = item as Outlook.Folder;
        if (null != childFolder)
        {
          // add this folder to the list.
          folders.Add(new Folder(childFolder, PrettyFolderPath(childFolder.FolderPath)));

          // Call EnumerateFolders using childFolder.
          EnumerateFolders(childFolder, folders);
        }
      }
    }
        public MailAttachmentTransform(int recurseDepth, MsOutlook._Application olApplication, bool disableAccessToDOMAttachments = false)
		{
			if (recurseDepth > AbsoluteMailNestingDepth || recurseDepth < 0)
				throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture,
					"Only supports a nesting level between 0 and {0}", AbsoluteMailNestingDepth), "recurseDepth");
			m_application = olApplication;
			m_nestingLimit = recurseDepth;
			if (m_application == null)
			{
				try
				{
					m_application = new WsApplication(new MsOutlook.Application(), false);
				}
				catch (COMException)
				{
					Thread.Sleep(1000);
                    m_application = new WsApplication(new MsOutlook.Application(), false);
				}
			}

            if (disableAccessToDOMAttachments)
            {
				m_mat = Oif.CreateWSMailAttachmentTransform();
            }
			else
            {				
				m_mat = Oif.CreateOOMWSMailAttachmentTransform();
            }
			m_mat.OutlookApp = m_application;
		}
        private Outlook.Explorer m_WindowsNew; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// <c>OutlookExplorerWrapper</c>
        /// Create new instance for explorer class 
        /// </summary>
        /// <param name="explorer"></param>
        public OutlookExplorerWrapper(Outlook.Explorer explorer)
        {
            //m_WindowsNew = explorer;
            m_WindowsNew = ThisAddIn.OutlookObj.ActiveExplorer();
            cbWidget = m_WindowsNew.CommandBars;
            ((Outlook.ExplorerEvents_Event)explorer).Close += new Microsoft.Office.Interop.Outlook.ExplorerEvents_CloseEventHandler(OutlookExplorerNew_Close);
        }
Esempio n. 12
0
 private bool isRulepresent(Outlook.Rules rules,string mailaddress)
 {
     foreach (Outlook.Rule r in rules)
     {
         if (r.RuleType == Outlook.OlRuleType.olRuleReceive)
         {
             Outlook.RuleConditions rcs = r.Conditions;
             foreach (Outlook.RuleCondition rc in rcs)
             {
                 if (rc.ConditionType == Outlook.OlRuleConditionType.olConditionFrom)
                 {
                     Outlook.ToOrFromRuleCondition tf = r.Conditions.From;
                     Outlook.Recipients recipients = tf.Recipients;
                     foreach (Outlook.Recipient recipient in recipients)
                     {
                         if (recipient.Address.Equals(mailaddress))
                         {
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Esempio n. 13
0
        // 我们让公共方法具有此行为,以便
        // 能够独立于 NewInspector 事件调用该行为。
        // 目的是为了允许争用条件,
        // 在此条件下可以在挂钩 NewInspector 事件之前进行
        // 功能区回调。
        public Office.Core.CustomTaskPane CreateTaskPane(
            Outlook.Inspector inspector)
        {
            Office.Core.CustomTaskPane taskpane = null;

            try
            {
                // 创建一个新的任务窗格,并将其宽度设置为与
                // SimpleControl 宽度匹配。
                taskpane = _taskPaneConnector.CreateTaskPane(
                        _controlProgId, _controlTitle, inspector);
                if (taskpane != null)
                {

                    taskpane.Width = 230;

                    // 将任务窗格映射到检查器,并将其缓存
                    // 在集合中。
                    _uiElements.Add(new UserInterfaceContainer(
                        inspector, taskpane, _ribbonConnector));
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return taskpane;
        }
Esempio n. 14
0
        public static void SetCompanies(Outlook.ContactItem source, Contact destination)
        {
            destination.Organizations.Clear();

            if (!string.IsNullOrEmpty(source.Companies))
            {
                //Companies are expected to be in form of "[Company]; [Company]".
                string[] companiesRaw = source.Companies.Split(';');
                foreach (string companyRaw in companiesRaw)
                {
                    Organization company = new Organization();
                    company.Name = (destination.Organizations.Count == 0) ? source.CompanyName : null;
                    company.Title = (destination.Organizations.Count == 0)? source.JobTitle : null;
                    company.Department = (destination.Organizations.Count == 0) ? source.Department : null;
                    company.Primary = destination.Organizations.Count == 0;
                    company.Rel = ContactsRelationships.IsWork;
                    destination.Organizations.Add(company);
                }
            }

            if (destination.Organizations.Count == 0 && (!string.IsNullOrEmpty(source.CompanyName) || !string.IsNullOrEmpty(source.JobTitle) || !string.IsNullOrEmpty(source.Department)))
            {
                Organization company = new Organization();
                company.Name = source.CompanyName;
                company.Title = source.JobTitle;
                company.Department = source.Department;
                company.Primary = true;
                company.Rel = ContactsRelationships.IsWork;
                destination.Organizations.Add(company);
            }
        }
Esempio n. 15
0
 void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
 {
     if (Selection[1] is Outlook.MailItem)
     {
         OnMailItenContextMenu(CommandBar, Selection);
     }
 }
Esempio n. 16
0
        public static bool ContainsGroup(Outlook.ContactItem outlookContact, string group)
        {
            if (outlookContact.Categories == null)
                return false;

            return outlookContact.Categories.Contains(group);
        }
Esempio n. 17
0
 public SettingsManager(Outlook.Application app)
 {
     Application = app;
     this.profile = Application.Session.CurrentProfileName;
     Outlook.Folder oInbox = (Outlook.Folder)Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
     this.storage = oInbox.GetStorage("calcifyStore", Outlook.OlStorageIdentifierType.olIdentifyBySubject);
 }
Esempio n. 18
0
		private RWSMail(MSOutlook.MailItem mailItem)
		{
			m_oif = new OutlookIImplFactory();
            string assemblyLocation = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            if (string.IsNullOrEmpty(assemblyLocation))
                throw new ArgumentNullException("Unable to get assembly location");

            assemblyLocation = new Uri(assemblyLocation).LocalPath;

            RedemptionLoader.DllLocation32Bit = Path.Combine(assemblyLocation, "redemption.dll");


            m_safeMailItem = RedemptionLoader.new_SafeMailItem();
            _wsMailItem = mailItem;

            if (mailItem is WsMailItem)
            {
                m_safeMailItem.Item = _wsMailItem.UnSafeMailItem;
            }
            else
            {
                // Needed for the unit tests
                m_safeMailItem.Item = _wsMailItem;
            }

		    m_application = mailItem.Application;
		}
Esempio n. 19
0
        public MailItemInfo(Outlook.MailItem mailItem)
        {
            var mailItemFolder = IOfficeConnectGlobals.TryGetMailItemFolder(mailItem);

            _currentMailItemEntryID = mailItem.EntryID;
            _currentMailItemFolderEntryID = mailItemFolder.EntryID;
            _currentMailItemFolderStoreID = mailItemFolder.StoreID;

            var inboxFolder = mailItemFolder.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            _isInboxItem = _currentMailItemFolderEntryID == inboxFolder.EntryID;

            _fromEmailAddress = mailItem.SenderEmailAddress;
            _fromDisplayName = mailItem.SenderName;

            _subject = mailItem.Subject;

            _received = mailItem.ReceivedTime;
            _sent = mailItem.SentOn;
            _hasBeenSent = mailItem.Sent;

            _created = mailItem.CreationTime;
            _bodyPlainText = mailItem.Body;
            _bodyHTML = mailItem.HTMLBody;

            foreach (var thisRecipient in mailItem.Recipients)
            {
                var r = thisRecipient as Outlook.Recipient;

                if (r != null)
                {
                    _recipients.Add(new MailRecipientInfo(r));
                }
            }
        }
Esempio n. 20
0
        public FormRegionControls(Outlook.FormRegion region)
        {
            if (region != null)
            {
                try
                {
                    // 缓存对此区域及其
                    // 检查器以及此区域上的控件的引用。
                    _inspector = region.Inspector;
                    _form = region.Form as UserForm;
                    _ordersText = _form.Controls.Item(_ordersTextBoxName)
                        as Microsoft.Vbe.Interop.Forms.TextBox;
                    _coffeeList = _form.Controls.Item(_formRegionListBoxName)
                        as Outlook.OlkListBox;

                    // 使用任意字符串填充此列表框。
                    for (int i = 0; i < _listItems.Length; i++)
                    {
                        _coffeeList.AddItem(_listItems[i], i);
                    }
                    _coffeeList.Change += new
                        Outlook.OlkListBoxEvents_ChangeEventHandler(
                        _coffeeList_Change);
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Esempio n. 21
0
        private Outlook.Inspector m_Window; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new instance of the tracking class for a particular 
        /// inspector and custom task pane.
        /// </summary>
        /// <param name="inspector">A new inspector window to track</param>
        ///<remarks></remarks>
        public OutlookInspector(Outlook.Inspector inspector)
        {
            m_Window = inspector;

            // Hookup the close event
            ((Outlook.InspectorEvents_Event)inspector).Close +=
                new Outlook.InspectorEvents_CloseEventHandler(
                OutlookInspectorWindow_Close);

            taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
                new UserControl1(), "My task pane", m_Window);
            taskPane.Visible = true;
            //  taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);

            // Hookup item-level events as needed
            // For example, the following code hooks up PropertyChange
            // event for a ContactItem
            //OutlookItem olItem = new OutlookItem(inspector.CurrentItem);
            //if(olItem.Class==Outlook.OlObjectClass.olContact)
            //{
            //    m_Contact = olItem.InnerObject as Outlook.ContactItem;
            //    m_Contact.PropertyChange +=
            //        new Outlook.ItemEvents_10_PropertyChangeEventHandler(
            //        m_Contact_PropertyChange);
            //}
        }
        public static void SetGoogleOutlookContactId(string syncProfile, ContactEntry googleContact, Outlook.ContactItem outlookContact)
        {
            if (outlookContact.EntryID == null)
                throw new Exception("Must save outlook contact before getting id");

            SetGoogleOutlookContactId(syncProfile, googleContact, GetOutlookId(outlookContact));
        }
        public static bool ArchiveRootFolderExists(Outlook.NameSpace sessionNamespace, BrugerInfo brugerInfo)
        {
            using (var _dc = new iorunEntities())
            {
                var userSettings = _dc.UserSettings.Where(us => us.US_UserGUID == brugerInfo.ID).ToList().Single();
                var rootArchiveFolderStoreID = userSettings.US_ExchangeStore;
                var rootArchiveFolderEntryID = userSettings.US_ExchangeEntry;

                try
                {
                    var rootArchiveFolder = sessionNamespace.GetFolderFromID(rootArchiveFolderEntryID, rootArchiveFolderStoreID);
                    if (rootArchiveFolder == null)
                    {
                        return false;
                    }

                    return true;
                }
                catch (COMException ce)
                {
                    log.Info(string.Format("ArchiveRootFolderExists: Findes ikke. COM fejl: {0}", ce.Message), ce);

                    return false;
                }
            }
        }
Esempio n. 24
0
        public static Outlook.MailItem GetMailItemFromId(Outlook.Application app, string entryId)
        {
            var nameSpace = app.GetNamespace("MAPI") as Outlook.NameSpace;

            var item=nameSpace.GetItemFromID(entryId);
            var mailItem = item as Outlook.MailItem;
            return mailItem;
        }
Esempio n. 25
0
 public void addRecipient(String recipient, Outlook.OlMailRecipientType olMailRecipientType)
 {
     if (ExpressionValidator.ExpressionValidator.isEmail(recipient.Replace(" ","")))
     {
         Outlook.Recipient olRecipient = (Outlook.Recipient)olRecipients.Add(recipient);
         olRecipient.Type = (int)olMailRecipientType;
     }
 }
Esempio n. 26
0
		public OutlookNewMailSource(IHostApplicationProvider hostAppProvider, MsOutlook.MailItem mailItem)
			: base(hostAppProvider)
		{
			Precedence = -1;

			Context = Interfaces.Context.Modified;
			DataSource = InitialiseDataSource(mailItem);
		}
 public static string GetOutlookGoogleContactId(Syncronizer sync, Outlook.ContactItem outlookContact)
 {
     Outlook.UserProperty idProp = outlookContact.UserProperties[sync.OutlookPropertyNameId];
     string id = (string)idProp.Value;
     if (id == null)
         throw new Exception();
     return id;
 }
 public SendMail(Outlook.Application application, string subject, string body, string to, string smtpAddres)
 {
     this.application = application;
     this.subject = subject;
     this.body = body;
     this.to = to;
     this.smtpAddres = smtpAddres;
 }
Esempio n. 29
0
 private void PopulateFolders(Outlook.Folders folders, List<Outlook.MAPIFolder> folderList)
 {
     foreach (Outlook.MAPIFolder folder in folders)
     {
         folderList.Add(folder);
         PopulateFolders(folder.Folders, folderList);
     }
 }
        /* Upload fichier .MSG */
        public void addContentFile(Outlook.MailItem mailItem, string docRef)
        {
            // Extraction et copie en local du message Outlook au format MSG
            string filename = mailItem.Subject == null ? "Sans Objet.msg" : AddSlashes(mailItem.Subject) + ".msg";
            string fsFilename = repTemp + AddSlashes(filename);

            mailItem.SaveAs(fsFilename, Outlook.OlSaveAsType.olMSG);
            EnvoiPJ(filename, fsFilename, docRef);
        }
Esempio n. 31
0
        protected override void DoExecute(ref DateTime start)
        {
            Excel.Application objExl;
            bool   ReadOnly = true, lbExit;
            int    row, i, j;
            string EmailTo, EmailSubject, EmailMessage;

            objExl = new Excel.Application();
            try
            {
                objExl.DisplayAlerts = false;
                objExl.Visible       = true;
                Excel.Workbook wb = objExl.Workbooks.Open(ExcelFile, false, ReadOnly);
                try
                {
                    Excel.Worksheet xlWorkSheet;

                    xlWorkSheet         = wb.Worksheets.get_Item(1);
                    Outlook.VisibleMode = true;
                    // I go through Excel to send all the emails
                    lbExit = false;
                    row    = 2;
                    do
                    {
                        CheckAbort();
                        EmailTo = ToString(xlWorkSheet.Cells[row, "A"].Text).Trim();
                        if (EmailTo.Length == 0)
                        {
                            lbExit = true;
                        }
                        else
                        {
                            Balloon(EmailTo);
                            EmailSubject = ToString(xlWorkSheet.Cells[row, "B"].Text).Trim();
                            EmailMessage = ToString(xlWorkSheet.Cells[row, "C"].Text).Trim();
                            Outlook.SendEmail(EmailTo, EmailSubject, EmailMessage);
                        }
                        row++;
                    } while (!lbExit);
                    // I go through all the emails in the inbox
                    List <Outlook.MAPIFolder> folders = new List <Outlook.MAPIFolder>();
                    folders.Add(Outlook.Inbox);
                    j = 0;
                    i = 0;
                    while ((i < folders.Count) && (j < 200))
                    {
                        CheckAbort();
                        Outlook.MAPIFolder folder = folders.ElementAt(i);
                        row = 1;
                        while (row <= folder.Folders.Count) // I add all the folders
                        {
                            folders.Add(Outlook.Inbox.Folders[row]);
                            row++;
                        }
                        row = 1;
                        while (row <= folder.Items.Count) // I show all the emails
                        {
                            CheckAbort();
                            Outlook.MailItem mail = folder.Items[row];
                            Balloon(folder.Name + LF + mail.SenderEmailAddress + LF + mail.Subject);
                            row++;
                            j++;
                        }
                        i++;
                    }
                }
                finally
                {
                    wb.Close(false);
                }
            }
            finally
            {
                try
                {
                    objExl.Visible = false;
                }
                finally
                {
                    try { objExl.Quit(); } catch { }
                }
            }
        }