zoukankan      html  css  js  c++  java
  • 使用QTP查找邮件

    参考:

    http://www.51testing.com/?uid-173503-action-viewspace-itemid-201647

     

     

    Function getMailContent(strFolderWithinInbox, strSenderName, nMinuteBefore)
        'nMinuteBefore, mail received time more than nMinuteBefore minutes before Now, not be a target.
        'Create or get outlook instance.
        Set appOutlook = CreateObject("Outlook.Application")
        Set myFolder = appOutlook.GetNamespace("MAPI").GetDefaultFolder(6)

        'Set your sub folder when you need, i.e. "working" in your Inbox.
        If Len(strFolderWithinInbox) <> 0 Then
            Set myNewFolder = myFolder.Folders(strFolderWithinInbox)
            Set myItems = myNewFolder.Items
        Else
            Set myItems = myFolder.Items
        End If

        'If no letter found, exit action.
        If myItems.count = 0 Then ExitAction(0)

        'Iterate the items.
        Set myItem = myItems.GetFirst
        Dim i, bFound, strLetterBody, strLetterSubject, mailTime
        strLetterBody = ""
        bFound = False
        Do While Typename(myItem) <> "Nothing"
            'oShell.Popup "Item #" & i & ":" & myItem.Subject, 2, "hello"
            If (myItem.SenderName = strSenderName) Then
                mailTime = myItem.ReceivedTime
                If (DateDiff("n", Now, mailTime) < nMinuteBefore) Then
                    strLetterBody = myItem.Body
                    strLetterSubject = myItem.Subject
                    Exit Do
                End If
            End If
            Set myItem = myItems.GetNext
        Loop

        getMailContent = strLetterBody

    'Clear resource.
        Set itm = Nothing
        Set myFolder = Nothing
        Set appOutlook = Nothing
        Set Shell = Nothing
    End Function

  • 相关阅读:
    PHP循环控制语句中的“for”循环
    PHP循环控制语句之“do...while”
    PHP循环控制语句之“while”
    PHP跳出循环之“continue”
    PHP跳出循环之“break”
    PHP控制语句之“switch”语句
    PHP条件控制语句之“elseif语句”
    PHP控制语句之“if...else”语句
    PHP条件控制语句之“if语句”
    三元运算符
  • 原文地址:https://www.cnblogs.com/testware/p/1933994.html
Copyright © 2011-2022 走看看