Solved

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

Posted on 2014-02-23
6
401 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now