View Single Post
  #8  
Old February 24th 08, 04:07 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Automate attachment selection

Because Word is your email editor, you would need to create this macro in Word. Insert a new module in the Normal.dot template and put the macro there.

Sub InsertFile()
' requires reference to Microsoft Outlook library
Dim objOL As Outlook.Application
Dim objInsp As Outlook.Inspector
Dim objMail As Outlook.MailItem
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
Set objInsp = objOL.ActiveInspector
Set objMail = objInsp.CurrentItem
objMail.Attachments.Add "C:\data\myfile.txt"
Set objMail = Nothing
Set objInsp = Nothing
Set objOL = Nothing
End Sub

You can then run it from an open Outlook message by using Alt+F8 or add a custom toolbar that includes that macro as a button.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Padds" wrote in message ...
Outlook 2003 with Word 2003 as the email editor.

VBA Macros don't fall into my area of expertise - could you give me some
pointers on where I should start?

"Sue Mosher [MVP-Outlook]" wrote:

An Outlook custom form is not a good solution for this scenario, given that custom forms can cause attachment problems for external recipients.

Instead, you could write a little VBA macro to attach the file.

"Padds" wrote in message ...
This won't work in my situation I'm afraid.

The attachment will be sent to external recipients (I should have specified
that in my original question).

Thank's for your reply though - do you have any more suggestions?

"karlman" wrote:

On Jan 10, 3:12 am, Padds wrote:
I would like to create a form, essentially a newsletter, that will
automatically attach a file from a particular location each time the form is
opened. The contents of the file change, however, the name and path remain
constant.

e.g.
I would like G:\folder1\file1.zip to be attached to a form each time the
form is opened (rather than have the attachment saved along with the form
which would mean that the new data in this file would not be attached after
the form was created).

Is this possible? If so, how do I do it?

How about just create a link to the file in the form. The actual file
will not be saved in the form, just the link information on wher it is
located. You could change the file all you wanted as long as it's name
remained the same.

Karl



Ads