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
Register
Register | 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 14th, 2007, 09:42 AM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel VBA - Send email with html message body

Hi Friends,

I wonder if anyone can give me some instruction on how to send through Excel an email with an HTML file as message body.
I tried something out but does'nt recognize the html but placed it in the body message as text.

I know how to send email and even how to send it with a spreadsheet as message body, but an HTML message body would give me much more flexibility.

Thanks a lot,
Elad.
Reply With Quote
  #2 (permalink)  
Old July 16th, 2007, 03:28 PM
Friend of Wrox
Points: 513, Level: 8
Points: 513, Level: 8 Points: 513, Level: 8 Points: 513, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2007
Location: Davenport, IA, USA.
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Not sure how you are sending eMail, however I'd suggest instantiating an Outlook object and sending the mail in Outlook natively.

First, Add the resource "Microsoft Outlook 11.0 Object Library" (Or whatever Outlook object library you have). The code will be:
-------------------------------------------------------------------
Dim MailObj as Outlook.MailItem
MailObj = Outlook.Application.CreateItem(olMailItem)
With MailObj
  .To = "Who@Where.Com"
  .CC = "Whoelse@Whereelse.Com"
  .Subject = "The Subject (HTML Format)"
  .BodyFormat = olFormatHTML
  .HTMLBody = "HTML Content"
  .Display 'Can be .Send but prompts for user intervention before sending without 3rd party software like ClickYes
End With
-------------------------------------------------------------------

Reply With Quote
Reply


Thread Tools
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
reading a html doc into outlook body message matpen Word VBA 5 June 21st, 2009 10:19 PM
Corrupt HTML Body in CDO email patwadd Classic ASP Professional 3 July 26th, 2007 05:14 PM
Send Message to Email inbaa ASP.NET 1.0 and 1.1 Professional 2 August 28th, 2006 05:45 AM
how to send HTML email by using CDO.Message ittech Classic ASP Basics 2 January 10th, 2006 05:49 PM
How to send HTML email by using CDO.Message ittech Classic ASP Components 1 January 10th, 2006 05:48 PM



All times are GMT -4. The time now is 10:34 AM.


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