Document as Outlook Attachment

J

jeanmac

Hello

I wonder if anyone could help me with this. I haven't done much programming
full stop, and even less in Word. What I want to do is send a Word document
based on a template as an attachment in Outlook. However, I want the cc
field to always have the same email address in it. In addition to this I
would like the users to be able to choose who they want to send to from their
address list, add any other cc addresses and then type what they want in the
subject and body of the message. The only code I have found so far can
either prompt for an Email address or hard code one and then send the
message. I want to open the message so that they can edit it before sending.
Can anyone help? I'd really appreciate that.

The code I have so far is:

Sub SendDocumentAsAttachment()

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
'Set the recipient for a copy
.CC = "(e-mail address removed)"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Send
End With

'If we started Outlook from code, then close it
If bStarted Then
oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
 
P

Perry

message. I want to open the message so that they can edit it before

Apart from all the other things you'd like to do in yr msg, replace .Send by
..Display
like examplified below.
This way, the msg will remain onscreen for the user to edit. This sounds
like the abovequoted, imo.

'Replace this
With oItem
'all the other things to oItem
.Send
End With
'end replace

by this
With oItem
'all the other things to oItem
.Send
End With
'end by

Krgrds,
Perry
 
J

jeanmac

Thank you so much!!! I've tried all sorts of ways out, but didn't think of
Display. Without people like you, people like me would continue to be in the
dark. I wish I had your brain...

Jeanmac
 

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