Is it possible to have file automatically e-mailed once saved?

  • Thread starter Thread starter JK
  • Start date Start date
J

JK

I wish to have a simple 'staff rota' template document automatically sent via
email to employees, once document template is updated and saved.
 
It depends on your definition of 'automatic'. You could use a macro attached
to a toolbar button to send a copy of the document to a group of employees.
Set up a distribution list in Outlook of all the employees that you want to
send the document to, then change the name of the list in the place
indicated in the following macro. Click the button and the document will be
sent to all the people in that group from the default Outlook profile.

And before you ask, this only works with Outlook!

http://www.gmayor.com/installing_macro.htm

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
ActiveDocument.Save
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
'**********************************
.To = "Distribution List Name" 'send to this address
'**********************************
.Subject = "Staff Rota - " & Format(Date, "d MMM yyyy") 'This is the
message subject
.Body = "See attached document" ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
'**********************************
'If you want to view the message before it goes
'change the line above from .Send to .Display
'Otherwise the message is sent straight to the Outbox
'and if you have Outlook set to send mail immediately,
'it will simply be Sent
'with no obvious sign that Outlook has operated.
'Apart from the copy in the Outlook Sent folder
'**********************************
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Staff Grade and Shift 0
Excel Is this possible?? 3
Excel 2 into 1 6
Problem: Template Field Code unlinks automatically 2
One-time insertion of text from other files 1
Word 2003 - Save As 4
Why save templates to My Documents? 1
table of contest 7

Back
Top