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

  • 相关阅读:
    汇编实验四
    汇编实验三
    C语言常用标准库函数
    实验一
    NGUI的缓动
    unity之Hashtable ArrayList List
    有关Unity 的一些 笔记之
    有关Unity 的一些 笔记之场景
    有关Unity 的一些 笔记之prefab
    有关Unity 的一些 笔记之消息事件
  • 原文地址:https://www.cnblogs.com/testware/p/1933994.html
Copyright © 2011-2022 走看看