Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 9th, 2005, 04:59 AM
Registered User
Join Date: Feb 2005
Location: , , Switzerland.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to saimen
Default Send Mail from Word with formatted Body


Maybe this is a little bit off-topic because it's about Word & VBA and not Excel & VBA but I found that it fits best in this category...

I'm having a word document which can be sent to Outlook automatically. This is done by creating a new Outlook message (specified: outlook invitation) and then attaching the (temporary saved) doc-file as attachment to the message. It's all done with vba and looks like this:
Private Sub einladungErstellen()
    Dim objOL   'As Outlook.Application
    Dim objAppt 'As Outlook.AppointmentItem
    Dim attPath As String
    Const olAppointmentItem = 1
    Const olMeeting = 1

    attPath = Tempfile
    Set objOL = CreateObject("Outlook.Application")
    Set objAppt = objOL.CreateItem(olAppointmentItem)
    With objAppt
        .Subject = Title
        .Start = Startdate
        .End = Enddate
        .Location = RoomName
        .MeetingStatus = olMeeting ' make it a meeting request
        .Attachments.Add attPath
        .Body = "This is a test-text in the message body..."
    End With

    Set objAppt = Nothing
    Set objOL = Nothing
    Kill Tempdatei
End Sub
When I run the code, everything is working well and without any problems. But I would like to paste the formatted content of the word file directly to the message body. At the moment, I only know how to send unformatted text to the message body:
objAppt.Body = "This is my text"
How can I send formatted text as body content?

=> Maybe one could do this with a complete different approach: It's possible to copy the worddocument-content to clipboard and then paste it manually in the generated outlook message with 'ctrl+v'. Would it be possible to automate this?

thank you,

Reply With Quote
  #2 (permalink)  
Old February 10th, 2005, 07:53 AM
Friend of Wrox
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts


Have a look at this link.


The solution involves asving your word document as an HTML file and the subsequently setting the HTMLbody property of the appiontment item to be equal to the html code of the saved word file.

The solution you were alluding to would be to use the SendKeys method in VBA (have a look in Help for more info). Whilst it would work it is to be avoided if possible due to the sorts of errors that can crop up.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
text file in the body of e-mail mlov83 Word VBA 1 May 1st, 2008 09:18 AM
HTML formatted mail goes to BadMail. Why? nancy Classic ASP Basics 12 August 24th, 2004 10:19 AM
Sending a CSS formatted HTML mail madhukp Classic ASP Basics 4 June 17th, 2004 11:30 PM

All times are GMT -4. The time now is 08:24 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.