Solved

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

Posted on 2014-02-23
6
407 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
  • 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

If you don't know how to downgrade, my instructions below should be helpful.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

770 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