Sending e-mail through VBA

Dan190984

New Member
Joined
Mar 18, 2011
Messages
26
Hi all

I am currently running a macro with the following script.....

Sub Understood()
Dim OutlookApp As Object
Dim Mess As Object, Recip As String, rng As Range
Set rng = Range("B3:K28")
Recip = "name@companyname.com"
Set OutlookApp = CreateObject("Outlook.Application")
Set Mess = OutlookApp.CreateItem(olMailItem)
With Mess
.Subject = "Subject"
.HTMLBody = RangetoHTML(rng)
.Recipients.Add Recip
.cc = ['[sheetname.xlsm]workbookpage'!$g$9]
.Send
End With
End Sub

This works fine until the following issue occurs.....

When the page with this macro is sent to someone it is sent as a copy of a workbook so the CC section of the script fails as the filename is wrong.

How to I change this script to read that it needs to find G9 in the active workbook.

Thanks in advance
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try

Code:
.cc = ActiveWorkbook.Sheets("workbookpage").Range("G9").Value
 
Upvote 0
Hi

I get this error with that attempt

TypeMismatch: Unable to coerce parameter value. Outlook cannot translate your string

Any ideas?
 
Upvote 0
I didn't get an error but I didn'[t receive the .cc either :confused:

Make sure there is a valid e-mail address in that cell.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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