Send email where Body = Paste

M

Mary

I have the following code and want to paste the data copied from the first
part of the macro into the message body. I didn't see any examples of how to
paste, can anyone help?


*****************************************
Sub SendPage()
'
' SendPage Macro
'

'
Cells.Find(What:="bridge", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("B2:B7").Select
Selection.Copy

Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object


Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True


Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
oMailItem.Recipients.Add("(e-mail address removed)")
oRecipient.Type = 1 '1 = To, use 2 for cc

With oMailItem
.Subject = "**Outage Bridge**"
.Body = "paste here"
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
End With

End Sub
*********************************************


Thanks in advance!
Mary
 
J

JLGWhiz

That type of copy and paste cannot be done. You will need to set the values
of the range to a variable and then use the variable to fill in the Body of
the email.

You could concatenate the cell values of the range to form a single string
and then assign that to a variable.
Example:

myVar = Range("b2").Value & " " & Range("b3").Value & ...Range("b7").Value

Body = myVar
 
M

Mary

Thanks!!!

JLGWhiz said:
That type of copy and paste cannot be done. You will need to set the values
of the range to a variable and then use the variable to fill in the Body of
the email.

You could concatenate the cell values of the range to form a single string
and then assign that to a variable.
Example:

myVar = Range("b2").Value & " " & Range("b3").Value & ...Range("b7").Value

Body = myVar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top