Is it possible to yank a snippet of text from multiple emails?

1

I'm a web admin, and our website's error reporting is set up to send me emails when an error occurs.

I received about 300+ emails over the weekend, all with similar errors. I want to export a report from the emails that includes only a specific part of the text. Is this doable?

For reference:

[HTTP_HOST] => www.ourwebsite.com
[HTTP_REFERER] => http://www.refererwebsite.com

I'd like to export a list of all of the [HTTP_REFERER]'s from the list of emails.

I want to rule out that this was an attempted DDOS attack.

Edit: I realize that it might be doable to export this from the PHP superglobal, but I'm not familiar enough with it to know if it will do what I need it to.

Tiffany

Posted 2016-11-21T16:18:39.680

Reputation: 113

Answers

1

  1. In Outlook, go to Options, Customize Ribbon, and check the box next to "Developer" in the right-hand pane to enable the Developer options in the Ribbon.

  2. On the Ribbon, click Developer, then Visual Basic.

  3. Expand "Project1" and double-click on "ThisOutlookSession".

  4. Paste in this code:

    Sub dragonborn()
    'Declare variables
    Dim fus As Object, ro As Object, dah As String, wuld As RegExp, na As MatchCollection
        'Set up the regular expression defining what you want to look for
        Set wuld = New RegExp
        wuld.Pattern = "HTTP_REFERER\]\s*=>\s*(.+)"
        'Get your "Inbox" mailbox folder for the current open account
        Set fus = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
        'Loop through each item in Inbox that's an email
        For Each ro In fus.Items
            On Error GoTo here
            If TypeOf ro Is Outlook.MailItem Then
                dah = ro.Body
                'Attempt to match the email's body against your regex pattern
                Set na = wuld.Execute(dah)
                If na.Count > 0 Then
                    'Print the result to the Immediate Window (View -> Immediate Window) if there's a match
                    Debug.Print na.Item(0).SubMatches(0)
                End If
            End If
    here:
            On Error GoTo 0
        Next
    End Sub
    
  5. Run it (default hotkey: F5)

  6. Watch your Immediate Window.

allquixotic

Posted 2016-11-21T16:18:39.680

Reputation: 32 256

What was the purpose of the edit @Gareth ? I don't see any difference whatsoever in the post. Can you please explain? I'm not offended, just confused. – allquixotic – 2016-11-21T21:14:07.147

Just a minor edit to align the code with step 4. – Gaff – 2016-11-21T21:34:27.160