Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Range for Body of E-Mail

I am trying to use a range of cells in Excel as the body for an e-mail in
Outlook. The name for the range is 'DuesReceipt'. It doesn't seem to like
setting olBody to the range. Can someone help?

Public olToName As String
Public olccName As String
Public olbccName As String
Public olSubject As String
Public olBody As String
Public olRange As Object
Public olAttach1 As String

Sub SendReceipt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim SigString As String
Dim Signature As String

Dim xx As Integer
Dim yy As Integer
Dim zz As Integer

Set olApp = New Outlook.Application

SigString = "C:\Documents and Settings\...\Signatures\BillLong.txt"
If Dir(SigString) = "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

olToName = Range("K5").Value
olSubject = "Dues Receipt"
Set olRange = Range("DuesReceipt")

Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = olToName
.Subject = olSubject
.Body = olRange
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub

--
Bill @ UAMS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Range for Body of E-Mail

Maybe that DuesReceipt named range has more than one cell?

..Body = olRange.Cells(1).value

I'd declare olRange as a Range, too.

BillCPA wrote:

I am trying to use a range of cells in Excel as the body for an e-mail in
Outlook. The name for the range is 'DuesReceipt'. It doesn't seem to like
setting olBody to the range. Can someone help?

Public olToName As String
Public olccName As String
Public olbccName As String
Public olSubject As String
Public olBody As String
Public olRange As Object
Public olAttach1 As String

Sub SendReceipt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim SigString As String
Dim Signature As String

Dim xx As Integer
Dim yy As Integer
Dim zz As Integer

Set olApp = New Outlook.Application

SigString = "C:\Documents and Settings\...\Signatures\BillLong.txt"
If Dir(SigString) = "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

olToName = Range("K5").Value
olSubject = "Dues Receipt"
Set olRange = Range("DuesReceipt")

Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = olToName
.Subject = olSubject
.Body = olRange
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub

--
Bill @ UAMS


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Range for Body of E-Mail

Hi Bill

Or maybe you want this signature example
http://www.rondebruin.nl/mail/folder3/signature.htm


And use

Dim cell As Range
Dim strbody As String
For Each cell In ThisWorkbook.Sheets("Sheet1").Range("C1:C60")
strbody = strbody & cell.Value & vbNewLine
Next

Instead of

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"


See this page for HTML body examples
http://www.rondebruin.nl/mail/folder3/mail4.htm



--

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


"BillCPA" <Bill @ UAMS wrote in message ...
I am trying to use a range of cells in Excel as the body for an e-mail in
Outlook. The name for the range is 'DuesReceipt'. It doesn't seem to like
setting olBody to the range. Can someone help?

Public olToName As String
Public olccName As String
Public olbccName As String
Public olSubject As String
Public olBody As String
Public olRange As Object
Public olAttach1 As String

Sub SendReceipt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim SigString As String
Dim Signature As String

Dim xx As Integer
Dim yy As Integer
Dim zz As Integer

Set olApp = New Outlook.Application

SigString = "C:\Documents and Settings\...\Signatures\BillLong.txt"
If Dir(SigString) = "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

olToName = Range("K5").Value
olSubject = "Dues Receipt"
Set olRange = Range("DuesReceipt")

Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = olToName
.Subject = olSubject
.Body = olRange
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub

--
Bill @ UAMS

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Range for Body of E-Mail

DuesReceipt is cells A1:I9.

If I send it manually, I just highlight A1:I9, copy, and paste into the
e-mail - I guess it is like a table.

--
Bill @ UAMS


"Dave Peterson" wrote:

Maybe that DuesReceipt named range has more than one cell?

..Body = olRange.Cells(1).value

I'd declare olRange as a Range, too.

BillCPA wrote:

I am trying to use a range of cells in Excel as the body for an e-mail in
Outlook. The name for the range is 'DuesReceipt'. It doesn't seem to like
setting olBody to the range. Can someone help?

Public olToName As String
Public olccName As String
Public olbccName As String
Public olSubject As String
Public olBody As String
Public olRange As Object
Public olAttach1 As String

Sub SendReceipt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim SigString As String
Dim Signature As String

Dim xx As Integer
Dim yy As Integer
Dim zz As Integer

Set olApp = New Outlook.Application

SigString = "C:\Documents and Settings\...\Signatures\BillLong.txt"
If Dir(SigString) = "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

olToName = Range("K5").Value
olSubject = "Dues Receipt"
Set olRange = Range("DuesReceipt")

Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = olToName
.Subject = olSubject
.Body = olRange
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub

--
Bill @ UAMS


--

Dave Peterson
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Range for Body of E-Mail

Take a look at Ron de Bruin's site for working with Outlook and excel:
I'd start he
http://www.rondebruin.nl/tips.htm




BillCPA wrote:

DuesReceipt is cells A1:I9.

If I send it manually, I just highlight A1:I9, copy, and paste into the
e-mail - I guess it is like a table.

--
Bill @ UAMS

"Dave Peterson" wrote:

Maybe that DuesReceipt named range has more than one cell?

..Body = olRange.Cells(1).value

I'd declare olRange as a Range, too.

BillCPA wrote:

I am trying to use a range of cells in Excel as the body for an e-mail in
Outlook. The name for the range is 'DuesReceipt'. It doesn't seem to like
setting olBody to the range. Can someone help?

Public olToName As String
Public olccName As String
Public olbccName As String
Public olSubject As String
Public olBody As String
Public olRange As Object
Public olAttach1 As String

Sub SendReceipt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim SigString As String
Dim Signature As String

Dim xx As Integer
Dim yy As Integer
Dim zz As Integer

Set olApp = New Outlook.Application

SigString = "C:\Documents and Settings\...\Signatures\BillLong.txt"
If Dir(SigString) = "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

olToName = Range("K5").Value
olSubject = "Dues Receipt"
Set olRange = Range("DuesReceipt")

Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = olToName
.Subject = olSubject
.Body = olRange
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub

--
Bill @ UAMS


--

Dave Peterson
.


--

Dave Peterson
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
e-mail a range of cells as the body EXCELMACROS Excel Programming 7 May 14th 09 11:20 PM
Convert to HTML and e-mail selection as the body of the e-mail. ryanmhess Excel Programming 5 April 16th 09 01:28 AM
Mail as body Balu Excel Discussion (Misc queries) 1 May 30th 06 04:17 PM
Paste excel range into a mail item's body Tim[_44_] Excel Programming 0 January 31st 06 09:05 PM


All times are GMT +1. The time now is 09:52 AM.

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"