Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send webpage as body from Excel via Outlook

Status
Not open for further replies.

CoCe

MIS
Dec 17, 2002
4
NL
Hello,

I have an adresslist whom I want to mail a webpage (or better: the email should have a HTMLbody with pics and everything). This webpage should be the body of the e-mail (through Outlook). I've created some code to send the mails from Excel, but don't know how to create the bodytext.

Any suggestions?

Code so far:
Sub MailfromExcel()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim cell As Range
Application.ScreenUpdating = False
Set olApp = New Outlook.Application

'//Emailadres in kolom A
For Each cell In Sheets("Memberlist").Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Offset(0, 0).Value <> "" Then '//If empty do not select
If cell.Offset(0, 0).Value = "TRIGGER" Then '//If cells contains text 'trigger' then mail
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = cell.Offset(0, 17).Value '//Outlook adres
.CC = cell.Offset(0, 16).Value '//email adres
.Subject = "//Uw inlogcode voor de Golfsite//"

'//////here do I want to select the html code etc////
.Send
'//.Display
End With
Set olMail = Nothing
End If
End If
Next cell
Set olApp = Nothing
Application.ScreenUpdating = True
End Sub
 
Something like this ?
.BodyFormat = olFormatHTML
.HTMLbody = YourHTMLsource

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV,

But that's too easy. I don't want to insert the HTML code into VBA. I want to refer to a *.html file somewhere on my PC. Also images should be included.

It should be something like: .HTMLbody = "C:/Webpage.html"

Only this doesn't work offcourse..

Maybe there is a way to copy the contents in someway??

 
You may consider the .Attachments collection.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Doesn't do it either. It attaches the .html file as a separate file. I want to have the content of the .html as the body of the e-mail.
 
You may consider using the Scripting.FileSystemObject and the ReadAll method of the TextStream object.
However don't know how to handle the images.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top