Adjusting macro to send email

zioneye

New Member
Joined
Jul 13, 2008
Messages
5
For some reason this macro will send the workbook to Persons_Email_Addr
but not to Copy_To_Slay. What am I doing wrong?


Sub Email()
Dim Email_WB As Workbook
Dim Persons_Email_Addr As String
Dim Copy_To_Slay As String
Dim Email_Subj As String

On Error GoTo Email_Err
Set Email_WB = ActiveWorkbook
Persons_Email_Addr = "abc@abc.org"
Copy_To_Slay = "slay@abc.org"
Email_Subj = "New Travel Request"

Email_WB.SendMail Recipients:=Persons_Email_Addr, _
Subject:=Email_Subj

Email_Err:

End Sub
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,235
Office Version
  1. 365
Platform
  1. Windows
Why would it send an email to Copy_To_Slay?

You don't specify that as a recipient anywhere in the code.:eek:
 

zioneye

New Member
Joined
Jul 13, 2008
Messages
5
Thanks ... I new to this. How do I specify it as a recipeint in the code?
 

stemar

Board Regular
Joined
Mar 16, 2002
Messages
248
You can either send the message twice, once to each address, or create an array with the addresses - something like this:

dim MailAdd(2) as string
...
MailAdd(1) = "abc@abc.org"
MailAdd(2) = "slay@abc.org"
...
Email_WB.SendMail Recipients:=MailAdd(), _
Subject:=Email_Subj
...

HTH
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,797
Office Version
  1. 2019
Platform
  1. Windows
I'm not super up on email macros but I don't see any option for CC in .SendMail

It looks like its also possible to have multiple recipients on the To line and use an array to enter this data:

Code:
Dim a As Variant
a = Array("abc@abc.com", "abc@abc.com")
wb.SendMail Recipients:=a

AB

Edit: Doh! Yes this is what Norie did too....used an array called MailAdd...
 

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,093
Members
414,501
Latest member
mdhaumyu

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
Top