Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

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

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
ddantes
Asked:
ddantes
  • 3
  • 3
1 Solution
 
David LeeCommented:
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
 
ddantesAuthor Commented:
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
 
David LeeCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ddantesAuthor Commented:
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
 
David LeeCommented:
You're welcome!
0
 
ddantesAuthor Commented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now