Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default e-mail a range of cells as the body

I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default e-mail a range of cells as the body

fyi.. the loops work fine, I'mi getting a Run-time error "Array lower bound
must be zero"

I can make it work if I actually take the body off or just write a "something"
--
Thank you...


"EXCELMACROS" wrote:

I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default e-mail a range of cells as the body

TEXT looks like a range object.
try changing
.body = Text
to
.body = Text.Value


"EXCELMACROS" wrote in message
...
fyi.. the loops work fine, I'mi getting a Run-time error "Array lower
bound
must be zero"

I can make it work if I actually take the body off or just write a
"something"
--
Thank you...


"EXCELMACROS" wrote:

I want to be able to add a Range of cells to the body of my email, I'm
using
the following method but I'm not getting it to work. Does anyone knows
what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default e-mail a range of cells as the body

it didn't work, it actually sent the email with no body totally blank.
--
Thank you...


"EXCELMACROS" wrote:

I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default e-mail a range of cells as the body

See
http://www.rondebruin.nl/mail/folder3/mail4.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default e-mail a range of cells as the body

Thank you, one question, your method is asking me to create an html file, how
private is that? is that going to be published on the web? this is
sensitive information.
--
Thank you...


"Ron de Bruin" wrote:

See
http://www.rondebruin.nl/mail/folder3/mail4.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default e-mail a range of cells as the body

It will create a html file local
Then read the html into the mail
Delete the html

So it will not be published on the web


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
Thank you, one question, your method is asking me to create an html file, how
private is that? is that going to be published on the web? this is
sensitive information.
--
Thank you...


"Ron de Bruin" wrote:

See
http://www.rondebruin.nl/mail/folder3/mail4.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default e-mail a range of cells as the body

it works perfectly thank you a lot.
--
Thank you...


"Ron de Bruin" wrote:

It will create a html file local
Then read the html into the mail
Delete the html

So it will not be published on the web


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
Thank you, one question, your method is asking me to create an html file, how
private is that? is that going to be published on the web? this is
sensitive information.
--
Thank you...


"Ron de Bruin" wrote:

See
http://www.rondebruin.nl/mail/folder3/mail4.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"EXCELMACROS" wrote in message ...
I want to be able to add a Range of cells to the body of my email, I'm using
the following method but I'm not getting it to work. Does anyone knows what
I'm doing wrong?

For x = 1 To 5
For y = 1 To 5
If Sheets("Values").Range("H" & x) = Date + y And
IsEmpty(Sheets("Values").Range("N" & x)) Then

email = Sheets("Values").Range("H" & x).Offset(0, 4).Select
subj = "test"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Set Text = Range("H" & x - 1 & ":K" & x +
4).SpecialCells(xlCellTypeVisible)

With OutMail
.To = email
.CC = ""
.Subject = subj
.body = Text
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Values").Range("M" & x) = "e-mail sent"
End If
Next y
Next x
--
Thank you...



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
Mailing an excel range in the body of an e-mail Andy Tallent Excel Discussion (Misc queries) 4 April 25th 12 10:14 AM
Convert to HTML and e-mail selection as the body of the e-mail. ryanmhess Excel Programming 5 April 16th 09 01:28 AM
Paste excel range into a mail item's body Tim[_44_] Excel Programming 0 January 31st 06 09:05 PM
Range of Cells to create body of email Hahndo Excel Worksheet Functions 1 September 26th 05 07:00 PM
Paste range of cells on E-maul Msg Body kkhelil Excel Programming 1 July 25th 04 03:54 PM


All times are GMT +1. The time now is 04:27 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"