Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read receipt when Word document is opened

Posted on 2009-05-07
4
Medium Priority
?
591 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?  
0
Comment
Question by:thoban531
[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
4 Comments
 
LVL 17

Expert Comment

by:wobbled
ID: 24327111
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

0
 
LVL 17

Expert Comment

by:wobbled
ID: 24327135
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)
0
 

Author Comment

by:thoban531
ID: 24328946
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?  
0
 
LVL 17

Accepted Solution

by:
wobbled earned 150 total points
ID: 24395375
Sorry for the delay.  Here you go - remember to put the first part in the File Open bit as I explained above:



Private Sub Document_Open()
 
Dim bodytext As String
 
    bodytext = Now() & vbLf     'get time
    bodytext = bodytext & Application.UserName & vbLf   'get username of word user
    bodytext = bodytext & "whatever else you want"      'body text stuff
    
   Call SendDocumentInMail("Subject Line", "me@mymail.com", bodytext)
 
End Sub
 
Sub SendDocumentInMail(strSubject As String, strTo As String, strBody As String)
 
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
 
On Error Resume Next
 
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, start it from code
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
End If
 
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
 
With oItem
    'Set the recipient for the new email
   .To = strTo
    'Set the recipient for a copy
    '.CC = "recipient2@mail.com"
    'Set the subject
    .Subject = strSubject
    'The content of the document is used as the body for the email
    .Body = strBody
    .Send
End With
 
If bStarted Then
    'If we started Outlook from code, then close it
    oOutlookApp.Quit
End If
 
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
 
End Sub

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
Online collaboration can help businesses be more efficient, help employees grow their skills and foster a team environment.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

670 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