Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default e-mail selection from VBA

I have multiple sites that report overnight production numbers to a
distribution list. I would like to automate the process. Rather than send
an entire workbook for a few cells worth of data, I'd like to just send the
selected cells so as the body of the message so they can be easily red from a
hand held device. From File Send To Mail recipient I get an option to
either Send the entire workbook as an attachment, or Send the entire sheet as
the message body. If a range is selected and I choose the second option I
get exactly what I want. How do I do this from code? (I notice the Send
Button will say "Send this sheet" if no cells are selected, or "Send this
selection" if there are cells selected.)
--
Dan Cooley
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default e-mail selection from VBA

hi,
see this site
http://www.rondebruin.nl/sendmail.htm

regards
FSt1

"Dan Cooley" wrote:

I have multiple sites that report overnight production numbers to a
distribution list. I would like to automate the process. Rather than send
an entire workbook for a few cells worth of data, I'd like to just send the
selected cells so as the body of the message so they can be easily red from a
hand held device. From File Send To Mail recipient I get an option to
either Send the entire workbook as an attachment, or Send the entire sheet as
the message body. If a range is selected and I choose the second option I
get exactly what I want. How do I do this from code? (I notice the Send
Button will say "Send this sheet" if no cells are selected, or "Send this
selection" if there are cells selected.)
--
Dan Cooley

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default e-mail selection from VBA

Dim OutMail As Outlook.MailItem
Dim strbody As String
Sheets("Data").Activate
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
strbody = "Here is the report." & vbnewline & Range("A1:C12")


IncludeAttachments = false
With OutMail
.To =
.CC =
.BCC = ""
.Subject = "Daily Report"
.Body = strbody
.Display ' Or if you wish .Send

End With

Set OutMail = Nothing
Set OutApp = Nothing
--
Best wishes,

Jim


"Dan Cooley" wrote:

I have multiple sites that report overnight production numbers to a
distribution list. I would like to automate the process. Rather than send
an entire workbook for a few cells worth of data, I'd like to just send the
selected cells so as the body of the message so they can be easily red from a
hand held device. From File Send To Mail recipient I get an option to
either Send the entire workbook as an attachment, or Send the entire sheet as
the message body. If a range is selected and I choose the second option I
get exactly what I want. How do I do this from code? (I notice the Send
Button will say "Send this sheet" if no cells are selected, or "Send this
selection" if there are cells selected.)
--
Dan Cooley

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default e-mail selection from VBA

hi Dan,

I have revised what Jim posted as a String will not accept a Range object
larger than 1 cell. This is a quick and easy way, but not the prettiest. It
essentially, just creates a tab-delimited array in the message body (you need
to add a reference to the Outlook Object library):

Sub mailSend()
Dim OutMail As Outlook.MailItem
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)

Dim arrData As Variant
arrData = Sheet1.Range("YourRangeHere")

For ctr1 = LBound(arrData, 1) To UBound(arrData, 1)
For ctr2 = LBound(arrData, 2) To UBound(arrData, 2)
strbody = strbody & arrData(ctr1, ctr2) & vbTab
Next ctr2
strbody = strbody + vbNewLine
Next ctr1

IncludeAttachments = False
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Daily Report"
.Body = strbody
.send ' Or if you wish .Send

End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub


"Dan Cooley" wrote:

I have multiple sites that report overnight production numbers to a
distribution list. I would like to automate the process. Rather than send
an entire workbook for a few cells worth of data, I'd like to just send the
selected cells so as the body of the message so they can be easily red from a
hand held device. From File Send To Mail recipient I get an option to
either Send the entire workbook as an attachment, or Send the entire sheet as
the message body. If a range is selected and I choose the second option I
get exactly what I want. How do I do this from code? (I notice the Send
Button will say "Send this sheet" if no cells are selected, or "Send this
selection" if there are cells selected.)
--
Dan Cooley

Reply
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
How to send Excel selection using Live Mail RayS1010 Excel Discussion (Misc queries) 1 May 15th 08 11:33 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Copying Excel 2003 Selection into Outlook 2003 HTML E-Mail Message [email protected] Excel Discussion (Misc queries) 0 July 10th 06 03:07 PM
Error: cannot load the mail service. Check your mail installation. Brad Bowser Excel Discussion (Misc queries) 0 December 20th 05 10:03 PM


All times are GMT +1. The time now is 03:15 PM.

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

About Us

"It's about Microsoft Excel"