Can't include range in body of email

Lizard07

Board Regular
Joined
Jul 20, 2011
Messages
103
Hi I would like to have the text in range A1 and the text in Columns B and C displayed as the body of my email. The macro I currently have (below) will not include Columns B and C in the body even if I get rid of range A1 in the code.

Can you not have multiple cell contents as the email's body? Help, please!


Sub Send_StatusUpdate()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurrFile As String
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

CurrFile = ActiveWorkbook.FullName
Rows("3:3").Select
Selection.AutoFilter
Selection.AutoFilter Field:=6, Criteria1:="LEQO"


Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)
With olMail
.To = "lizblair07@gmail.com"
.CC = ""
.BCC = ""
.Subject = "Status Update"
.body = ActiveSheet.Range("A1").Text & ActiveSheet.Range("B:C").Text & vbCrLf
.Send
Rows("3:3").Select
Selection.AutoFilter


MsgBox ("Emails Sent For: LEQO")
End With
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Take a look at this sample I am using send keys to act as copy and paste


Sub EmailRange()
'*******************************************************************************
'This code requires you to Set the References. GoTo Tools > Reference >Search
'For Microsoft Outlook (A number) .Object Library and tick the box
'The following sample will look to email a filtered list of data with todays date
'Created by Trevor G
'May 2011
'*******************************************************************************
Dim OutlookApp As Outlook.Application
Dim MailSelection As Object
Dim cell As Range
Dim Subject As String
Dim EmailAddress As String
ThisWorkbook.Sheets("Karl To Elsie").Select
Range("A3").Select
Selection.AutoFilter
ActiveSheet.Range("$A$3:$j$35").AutoFilter Field:=4, Criteria1:= _
xlFilterToday, Operator:=xlFilterDynamic 'Adjust the range of cells
Range("A3").Select
ActiveCell.CurrentRegion.Copy
Set OutlookApp = CreateObject("Outlook.Application")
Set MailSelection = OutlookApp.CreateItem(0)
With MailSelection
.To = "trevor_g@xxxx.com" 'Change to email address
.Subject = "Invoice"
.Display 'Change to send once checked.
SendKeys "^({v})", True 'This is the same as using Paste
End With
' End If
'Next
End Sub
 
Upvote 0
I've been playing around with this and I still can't figure it out, I'm receiving an object not defined error....please help

Sub Send_StatusUpdate()
Dim OutlookApp As Outlook.Application
Dim MailSelection As Object
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim cell As Range
Dim Subject As String
Dim OutMail As Outlook.Application


Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
CurrFile = ActiveWorkbook.FullName
Rows("3:3").Select
Selection.AutoFilter
Selection.AutoFilter Field:=6, Criteria1:="LEQO"

Range("B3:C50").Select
ActiveCell.CurrentRegion.Copy
Set OutlookApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With olMail
.To = "kljklsdfjkl@email.com"
.Subject = "Status Update"
.Send
SendKeys "^({v})", True
End With
Rows("3:3").Select
Selection.AutoFilter

MsgBox ("Emails Sent For: LEQO")
End Sub
 
Upvote 0
That worked perfectly! I think theres even some more features I can add to it to make it customizable.

Thank-you!
 
Upvote 0
It's not my code. Do you mean a signature that Outlook can automatically append to a message? If so, I don't know, but I'm sure it's possible.

If instead you mean HTML-formatted text generated by your code, just include it in the HTMLBody property.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top