"VBS" retrieves outlook on-premises mailboxes

Source: Internet
Author: User

Implementation features: Use VBS to retrieve messages for a title in Outlook local mailbox today.

The code is as follows:

ConstC_date_format_mail_filter_from =1        'yyyy-m-d 0:00 AMConstC_date_format_mail_filter_to =2          'yyyy-m-d 11:59 PMFunctionCheckmail (Pmailfolder, Pmailtitle) on Error Resume Next    DimObjolappDimobjNameSpaceDimobjfolderDimstrfilter Checkmail=False    SetObjolapp =CreateObject("Outlook.Application")    SetobjNameSpace = Objolapp.getnamespace ("MAPI")    'olFolderInbox 6 default Inbox    Setobjfolder = Objnamespace.getdefaultfolder (6). Folders (Pmailfolder)IfErr.Number <>0  ThenAddlog ("Message Access error:"&err.description) Wscript.Quit-1    End If    'Filter Conditionsstrfilter ="[Subject] = '"&Pmailtitle _&"' and [Receivedtime] >= '"&FormatDate (now (), C_date_format_mail_filter_from) _&"' and [Receivedtime] <= '"& FormatDate (now (), c_date_format_mail_filter_to) &"'"    'Search    IfObjFolder.Items.Restrict (strfilter). Count >0  ThenCheckmail=True    End IfEnd Function'date FormattingFunctionformatdate (pDate, PFlag)Dimy, M, D formatdate=""    If IsDate(pDate) =False  Then Exit Functiony=CStr( Year(pDate)) m=CStr(Month(pDate)) d=CStr( Day(pDate))Select  CasePFlag CaseC_date_format_mail_filter_from'yyyy-m-d 0:00 AM fromFormatDate = y &"-"& M &"-"& D &"0:00 AM"         Casec_date_format_mail_filter_to'yyyy-m-d 11:59 PM toFormatDate = y &"-"& M &"-"& D &"11:59 PM"    End SelectEnd Function

"VBS" retrieves outlook on-premises mailboxes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.