Monday, 15 March 2010

vba - Outlook checks e-mails only in specific time frame -


I need a VBA Outlook macro that checks the items in the folder in a specific time limit. At the moment my code goes through all the fairs in the specified folder, but this is not an option because the folder has thousands of mails, so the macro takes it forever to run, any ideas, how to check the script For example, Mail: 3/16/2015 to 12:00 to 3/16/2015 2:00 pm and do not check any e-mails outside of that time frame?

I have this at present:

  sub ExportToExcel () dim appExcel Excel.Application dim form of Excel.Workbook Slow Excel.Worksheet dim RNG Excel.Range dim WorkbookFile as String Dimmed Outlook as Outlook 2007.MailItem Dim NMS Outlook.NameSpace is retarded as the Outlook.MAPIFLDM FLD itm object in the form of an object's folder path of an existing Excel workbook and File name workbookFile = "C: \ Users \ OutlookItems.xls" 'Export Export Folder NMS = ApplicationSetup GetNamespace ("MAPI") is to handle potential errors with the Fld = nms.PickFolder 'Select Folder dialog box. If FFD is nothing, then there are no mail messages to export "MSBBC", vbOKOnly, exit "_" error sub alcif fld.DefaultItemType & lt; & Gt; OlMailItem Then there is no mail message for "export export", vbOKOnly, _ "error" exit subfifth fld.Items.Count = 0 then MsgBox "no mail is exported to the message", vbOKOnly, _ "error "Exit the sub-end if you open the Excel workbook and set the appExcel = CreateObject (" Excel.Application ") set WKB = appExcel.Workbooks.Open (workbookFile) set = wkb.Sheets (1) wks.Activate appExcel Application.Visible = true set RNG = wks.Range ("A1") 'Copy Item item in the mail folder. In each ITM fld.Items if itm.Class = Set up Outlook.OlObjectClass.olMail then msg = itm if InStr (msg.Subject, "Error in WU_Send") & gt; 0 and dated ("H", msg. ston, now) & lt; = 2 then RNG Offset (0, 4). Value = msg.Bydy set RNG = RNG .offet (1, 0) and end and end and end and sub  

and the problem is in this special part:

< Pre> for each ITM in fld.Items if itm.Class = Set up Outlook.OlObjectClass.olmail then go to msg = itm if InStr (msg.Subject, "Error in WU_Send") & gt; 0 and dated ("H", msg. ston, now) & lt; = 2 then

How do I tell the code to only look at the specified hour and time on the e-mail? Ignore the rest?

Thanks or your answers, comments and suggestions in advance!

Instead of going through all the objects in the folder instead of using the / or methods of the items Have to do. For example:

  sub DemoFindNext () dim MyNamespace Outlook.NameSpace dim tdystart Date dated tdyend dated date myAppointments Outlook.Items slow currentAppointment Outlook.AppointmentItem set as MyNamespace = Application.GetNamespace In the form of as ("MAPI") tdystart = VBA.Format (now, "short date") tdyend = VBA.Format (now +1, "short date") set myAppointments = myNameSpace.GetDefaultFolder ( OlFolderCalendar). Items set currentAppointment = myAppointments.Find ("[Start]> gt; =" "and & quot; and" "" and [start]  

In addition to this you can find the application class method helpful. The main benefits of using advanced search method are listed below:

  • Search The second thread is carried out in the advanced search system after running automatically in the background, Thread is not required to run manually.
  • Any type of type, mail, appointment, calendar, notes etc. are likely to be searched in any place, i.e. beyond the scope of a fixed folder
  • DASL queries Restrict full support for (custom properties can also be used to search) and find / locate the next methods can be applied to a particular item collection. . You can read more about this in the filtering article in MSDN. To improve search performance, instant search keywords can be used if Instant Search is enabled for the store (see Store IsInstantSearchEnabled property in Store category).
  • You can stop the search process at any time by using the stop. Method of search class

No comments:

Post a Comment