Insert a File

M

Mike Faulkner

Hello

App: Outlook 2003
OS: Windows XP

I would like to create some VBA which would insert a file into the Body of
the email.

Set NewEmail = CreateItem(olMailItem)
With NewEmail
.Subject = "Test 1"
.Body = "<Insert a file... 'c:\pelikan\newsletter\Email_01.htm'>"
.Save
End With

NewEmail.Display

The HTM file contains a graphic and Webite hyperlinks etc. Any assistance
would be greatly appreciated.

Kind Regards
Mike
 
K

Ken Slovak - [MVP - Outlook]

What do you mean by "insert a file"? Do you want to insert the contents of a
file or to insert an attachment of a file? If you want to insert text from a
file you need to read the file contents as a string and insert that into the
HTMLBody property. Body is for plain text and knows nothing of HTML.
 
M

Mike Faulkner

Ken

I want to code the following:

In a new email click on:
1. Insert|File
2. Choose a file
3. Choose 'Insert as Text' from 'Insert' button

Regards
Mike
 
K

Ken Slovak - [MVP - Outlook]

How you'd do that depends on how you want to code it. If you want to use
the standard Outlook buttons you would handle the MailItem.AttachmentAdd()
event. That provides a handle to the added attachment. You would save that
to the file system and open and read it as a text string. How you'd do that
would depend on the type of file that was being attached.

I'd start by searching at www.outlookcode.com for code samples for reading
files and attaching file contents, as well as for modifying the HTMLBody of
mail items.
 

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

Top