We help IT Professionals succeed at work.

Read receipt when Word document is opened

857 Views
Last Modified: 2012-05-06
Greetings!  How can I have a read receipt Emailed to me when a Word document is opened?  I'd like to have the user name, time, date etc.  Is there a way to do this within word or are there third party applications?  
Comment
Watch Question

Commented:
You can do this by putting some code into the word document using the FileOpen command.  The only problem here is are the users internal (ie same company etc).  There are various was that you can do this, but not knowing their email client is going to be difficult to code for.  Also not all email clients will allow you to manipulate them outside of their application.

But to give you an idea

In the word document - add the following in the ThisDocument section of the VBA code


Option Explicit
 
Private Sub Document_Open()
 
Dim bodytext As String
 
    bodytext = Now() & vbLf
    bodytext = bodytext & "whatever else you want"
    
   Call SendNotesMail("subject", "", "me@this.com", bodytext, True)
 
End Sub
 
Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, bodytext As String, SaveIt As Boolean)
 
Dim Maildb As Object        'The mail database
Dim Username As String      'The current users notes name
Dim MailDbName As String    'The current users notes mail database name
Dim MailDoc As Object       'The mail document itself
Dim AttachME As Object      'The attachment richtextfile object
Dim Session As Object       'The notes session
Dim EmbedObj As Object      'The embedded object (Attachment)
 
On Error GoTo Err_SendNotesMail
 
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
 
    'Next line only works with 5.x and above. Replace password with your password
    'Session.Initialize ("password")
    
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string or using above password you can use other mailboxes.
    Username = Session.Username
    MailDbName = Left$(Username, 1) & Right$(Username, (Len(Username) - InStr(1, Username, " "))) & ".nsf"
    
    'Open the mail database in notes
    Set Maildb = Session.GetDatabase("", MailDbName)
 
     If Maildb.IsOpen = True Then
          'Already open for mail
     Else
         Maildb.OPENMAIL
     End If
     
    'Set up the new mail document
    Set MailDoc = Maildb.CreateDocument
        MailDoc.Form = "Memo"
        MailDoc.sendto = Recipient
        MailDoc.Subject = Subject
        MailDoc.body = bodytext
        MailDoc.SaveMessageOnSend = SaveIt
    
    'Set up the embedded object and attachment and attach it
    If Attachment <> "" Then
        Set AttachME = MailDoc.CreateRichTextItem("Attachment")
        Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment, "Attachment")
        MailDoc.CreateRichTextItem ("Attachment")
    End If
    
    'Send the document
    MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    MailDoc.Send 0, Recipient
    
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
    Exit Sub
 
Err_SendNotesMail:
    Exit Sub
 
End Sub

Open in new window

Commented:
The above was working on the principle that the user was using Lotus Notes as their email client.  If you are using outlook the just look at the Do.Cmd SendObject approach - much easier (a quick google will get you the code)

Author

Commented:
Thanks for the reply wobbled.  All users will be internal and on the same network.  I'm using Outlook as the mail client.  I'm not seeing where the user name, time and date who actually opened the document is being collected and sent to Notes in the code example you sent. Do you have any examples of doing it with Outlook?  
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.