Solved

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

Posted on 2014-02-23
6
410 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

749 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