word doc as attachment in mail (from a form)

  • Thread starter Thread starter geert.van.ransbeeck
  • Start date Start date
G

geert.van.ransbeeck

How can I generate a mail in a form (on clicking a button) which
permits me to get a Word
doc from my HD into an outlook 2003 - mail as an attachement?
 
Try this for your mail button:

Private Sub SendMail_Click()

Dim strFile As String

Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(olMailItem)

strFile = "C:\FilePath\File.doc"

With MailOutLook
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "Test"
.Body = "Test Body"
.Attachments.Add strFile
.Send
End With


End Sub

PJ
 
I should add that you won't get a message box or any kind of notification
that the item was sent. Check your Sent Items to see if your message is
there.
 
How can I generate a mail in a form (on clicking a button) which
permits me to get a Word
doc from my HD into an outlook 2003 - mail as an attachement?

Danny Lesandrini has some code that you can rip apart...
www.amazecreations.com/datafast

down toward the end of the code snippets, there's a sample Outlook
automation. Basically, you'd just create the mail message and then

olkMsg.Attachments.Add strDoc

not sure how you want to get the doc... OpenFileAPI? www.mvps.org/access/api
then it's the first or second one in the section.
 
Sure. The easiest thing to do is to add an input box to ask for what you
want the message to say.

Private Sub SendMail_Click()

Dim strFile As String
Dim strMsgBody As String

Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(olMailItem)

strFile = "C:\FilePath\File.doc"
strMsgBody = InputBox("Please enter message body", "Body")


With MailOutLook
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "Test"
.Body = strMsgBody
.Attachments.Add strFile
.Send
End With


End Sub

You would be limited to (I think) to 255 characters.

If that does not work for you or if you need to send certain people a
certain body (or subject, etc) there are a few other options that require a
bit more coding. Let me know.


PJ
 
Thanks a lot, works great, but how can I attach 2 word documents at
the same time?
 
Thanks Alex

And I want also add a second body text after my attachments are
dropped in the mail.
..Body= strFile2
doesn't work.
Any suggestion

Best regards
geert
 
Back
Top