Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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.
  #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
-------------------------------------------------------------------



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 06:49 PM
How to send HTML email by using CDO.Message ittech Classic ASP Components 1 January 10th, 2006 06:48 PM





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