LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default automate sending graph/pivot report in body of email

I need to automate sending a graph/pivot chart in the body of emai
using Outlook (will also have a little text). I've used the code belo
for putting text only in body of email, but can't quite figure out ho
to get the chart in there. Any help would be appreciated. Thx!

Code for putting cells in body of an email (modify slightly from code
pulled off site of Ron de Bruin):

Sub Mail_Selection_Outlook_Body()
Dim source As Range
Dim dest As Workbook
Dim myshape As Shape
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Application.ScreenUpdating = False
ActiveSheet.Copy
Set dest = ActiveWorkbook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Test Message"
.HTMLBody = RangetoHTML
.Send 'or use .Display
End With
dest.Close False
Set OutMail = Nothing
Set OutApp = Nothing
Set dest = Nothing
Application.ScreenUpdating = True
End Sub

Function RangetoHTML()
Dim fso As Object
Dim ts As Object
Dim TempFile As String
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
With ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=ActiveSheet.Name, _
source:=Selection.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Kill TempFile
End Functio

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Email pivot table report page. Lalit Mahadik Excel Discussion (Misc queries) 0 March 20th 10 11:13 PM
Automate Excel report to place certain data into existing report? Craig Harrison Excel Worksheet Functions 3 July 25th 06 01:54 PM
body of email disappears when I send an email from Excel ~A Excel Discussion (Misc queries) 0 February 25th 05 10:55 PM
When sending file via email, cannot paste Excel data into body of letter. Pierre Excel Discussion (Misc queries) 2 February 23rd 05 09:27 PM
Automate Graph of Pivot table Bruce Stemplewski Excel Programming 0 July 28th 03 04:19 AM


All times are GMT +1. The time now is 11:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"