Solved

Outlook Macro does not respond to an RNE from ReadNotify.com

Posted on 2014-02-23
6
411 Views
Last Modified: 2014-02-25
Running Outlook 2007, I subscribe to an Email tracking/notification service called ReadNotify.  When a tracked message is opened by the recipient, ReadNotify sends me a Read Notification Email (RNE).  I'd like Outlook to run a script when such an RNE arrives, but it does not run.  I believe this may be caused by an unusual file type associated with the RNE (see screenshot showing its properties).  Although the RNE is opened as an Outlook item, it is apparently not treated the same as an Outlook message.  Any suggestions as to how to work around this would be appreciated.  I'll attach a sample RNE, but it may become corrupted in the process of uploading it. RNE file type is "Report" not "Message"Read-Notification--vbs-test.msg
0
Comment
Question by:ddantes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 39884290
Hi, ddantes.

The item is a report, not a message.  If you'll post the code you're using, then I'll show you how to modify it to work against a report.
0
 

Author Comment

by:ddantes
ID: 39884350
Thank you for your offer!

Sub CheckForRNE(MyMail As MailItem)
On Error GoTo RNEerror
Dim strID, strSender, strSubject, strBody, strRNEfile, strAppData As String
Dim boolRNEsender, boolRNEsubject As Boolean
strID = MyMail.EntryID
strSender = MyMail.SenderEmailAddress
strSubject = MyMail.Subject
strBody = MyMail.Body
boolRNEsubject = InStr(UCase(strSubject), "READ NOTIFICATION:") > 0
boolRNEsender = InStr(UCase(strSender), "READNOTIFY") > 0 Or InStr(UCase(strSender), "WHOREADME") > 0
If boolRNEsubject And boolRNEsender Then
  Set oShell = CreateObject("WScript.Shell")
  strAppData = oShell.ExpandEnvironmentStrings("%APPDATA%")
  strRNEfile = strAppData & "\RENT\RNE\" & strID & ".txt"
  Open strRNEfile For Append As 1
  Print #1, strID
  Print #1, strSender
  Print #1, strSubject
  Print #1, strBody
  Close #1
End If
Exit Sub
RNEerror:
MsgBox "RENT OutMac CheckForRNE script error " & Err & " - " & Err.Description
Exit Sub
End Sub
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39884579
You'll need to use this code in place of your code.  This code must go in the ThisOutlookSession module.  Report items don't have a SenderEmailAddress property.  I've worked around that by using Outlook's PropertyAccessor object to read the sender's address from the unexposed properties of the object.

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim arrEID As Variant, _
        varEID As Variant, _
        olkItm As Object
    Dim strID, strSender, strSubject, strBody, strRNEfile, strAppData As String
    Dim boolRNEsender, boolRNEsubject As Boolean
    arrEID = Split(EntryIDCollection, ",")
    For Each varEID In arrEID
        Set olkItm = Session.GetItemFromID(varEID)
        Select Case olkItm.Class
            Case olMail, olReport
                strID = olkItm.EntryID
                strSender = GetSenderAddress(olkItm)
                strSubject = olkItm.Subject
                strBody = olkItm.Body
                boolRNEsubject = InStr(UCase(strSubject), "READ NOTIFICATION:") > 0
                boolRNEsender = InStr(UCase(strSender), "READNOTIFY") > 0 Or InStr(UCase(strSender), "WHOREADME") > 0
                If boolRNEsubject And boolRNEsender Then
                    Set oShell = CreateObject("WScript.Shell")
                    strAppData = oShell.ExpandEnvironmentStrings("%APPDATA%")
                    strRNEfile = strAppData & "\RENT\RNE\" & strID & ".txt"
                    Open strRNEfile For Append As 1
                    Print #1, strID
                    Print #1, strSender
                    Print #1, strSubject
                    Print #1, strBody
                    Close #1
                End If
        End Select
    Next
    Set olkItm = Nothing
End Sub
 
Private Function GetSenderAddress(olkMsg As Object) As String
    Dim olkPA As Outlook.PropertyAccessor
    On Error Resume Next
    Set olkPA = olkMsg.PropertyAccessor
    GetSenderAddress = olkPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1F001E")
    On Error GoTo 0
    Set olkPA = Nothing
End Function

Open in new window

0
Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

 

Author Comment

by:ddantes
ID: 39884613
Thank you for your code, and explanation.  The text file was produced!  There's still some work to be done, parsing data in the Report so it is completely intelligbile, but you've cleared up a big stumbling block.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39885169
You're welcome!
0
 

Author Comment

by:ddantes
ID: 39886248
Dear BlueDevilFan:  I've posted a related question, and would appreciate your participation if it is of interest:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28374041.html
Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't know how to downgrade, my instructions below should be helpful.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question