Search structured text in Outlook body

前端 未结 1 1581
悲哀的现实
悲哀的现实 2020-12-07 06:18

I need to find a line in a selected mail and copy it.

The line contains

Mailbox: ????????????????

The number of

相关标签:
1条回答
  • 2020-12-07 06:40
    finalSubj = ParseTextLinePair(initialBod, "Mailbox:")
    

    See "Listing 17.1. Extract data from a structured text block". https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/dd492012(v=office.12)

    Function ParseTextLinePair(strSource As String, strLabel As String)
    Dim intLocLabel As Integer
    Dim intLocCRLF As Integer
    Dim intLenLabel As Integer
    Dim strText As String
    
    ' locate the label in the source text
    intLocLabel = InStr(strSource, strLabel)
    intLenLabel = Len(strLabel)
        If intLocLabel > 0 Then
        intLocCRLF = InStr(intLocLabel, strSource, vbCrLf)
        If intLocCRLF > 0 Then
            intLocLabel = intLocLabel + intLenLabel
            strText = Mid(strSource, _
                            intLocLabel, _
                            intLocCRLF - intLocLabel)
        Else
            intLocLabel = Mid(strSource, intLocLabel + intLenLabel)
        End If
    End If
    ParseTextLinePair = Trim(strText)
    End Function
    

    Note: The OP indicated the line that worked was

    finalSubj = ParseTextLinePair((CStr(initialBod)), "Mailbox:") 
    
    0 讨论(0)
提交回复
热议问题