Competitions
CAT Prep
Upskill
Placements
MBA Co'26
RTI Response
Rankings
Score Vs. %ile
Salaries
Campus Tour

Excel tips and tricks - Project Management: How to send an email automatically through Excel VBA

Comments
 

Argha De

Hi, great article on excel automation. However, there are couple of things in the code which I would like to highlight in order to make it more generic. 1) The code assumes that there are only 3 rows of data (A2:A5). If any other row is automatically added, then the code would need to be changed again, which can be trouble some for people who are not conversant with programming. 2) The email sender sub routine is dealing with outlook only. If the user uses any other email app (mozilla thunderbird etc.), then the code might throw errors. Again changes has to be made programmatically. Resolutions: 1) Code: Dim sh as worksheet Dim n as integer set sh = ActiveWorkbook.ActiveSheet n=2 while sh.Range("A" & n) "" 'Prog logic n = n+1 wend 2) Use workbook.sendmail function: this is a generic method and can be used with any email app. However, options like CC, BCC or setting the body of the mail can not be done. For that outlook has to be used. But this can be useful for someone who is not using outlook. Syntax: ActiveWorkbook.Sendmail abc@gmail.com "Mail subject" if the requirement is to send the mail to multiple recipients at one go, then the mail ids can be stored in an array and the array can be used in sendmail. Hope this helps

15 Jun 2014, 06.15 PM

Argha De

A small correction: while sh.Range(“A” & n) ""

15 Jun 2014, 06.21 PM

Argha De

For some reason not-equality sign ( less than symbol followed by greater than symbol) is not getting printed in the comments. The while loop should be: while sh.Range(“A” & n) not-equality symbol “”

15 Jun 2014, 06.24 PM

Mini Mock Test

Final 19 Days to CAT 2024 Test-26

Participants: 107

Final 20 Days to CAT 2024 Test-26

Participants: 170
College Comparison Tool - Quiz Ad

Final 21 Days to CAT 2024 Test-25

Participants: 142

Final 22 Days to CAT 2024 Test-24

Participants: 162

Final 23 Days to CAT 2024 Test-23

Participants: 100

Final 24 Days to CAT 2024 Test-22

Participants: 154

Final 25 Days to CAT 2024 Test-21

Participants: 143

Final 26 Days to CAT 2024 Test-20

Participants: 190

Final 27 Days to CAT 2024 Test-19

Participants: 169

Final 28 Days to CAT 2024 Test-18

Participants: 166

Final 29 Days to CAT 2024 Test-17

Participants: 173

Final 30 Days to CAT 2024 Test-16

Participants: 192

Final 31 Days to CAT 2024 Test-15

Participants: 183

Final 32 Days to CAT 2024 Test-14

Participants: 188

Final 33 Days to CAT 2024 Test-13

Participants: 190

Final 34 Days to CAT 2024 Test-12

Participants: 224

CAT 2017 VARC SLOT- 2

Participants: 309

CAT 2017 DILR SLOT- 2

Participants: 152

CAT 2017 VARC SLOT- 1

Participants: 296

CAT 2017 DILR SLOT- 1

Participants: 105

CAT 2017 QUANT SLOT 1

Participants: 149

CAT 2017 QUANT SLOT 2

Participants: 69

CAT 2018 QUANT SLOT 2

Participants: 65

CAT 2018 QUANT SLOT 1

Participants: 106

CAT 2018 DILR SLOT- 2

Participants: 56

CAT 2018 DILR SLOT- 1

Participants: 81

CAT 2018 VARC SLOT- 2

Participants: 200

CAT 2018 VARC SLOT- 1

Participants: 293

Final 35 Days to CAT 2024 Test-11

Participants: 151

Final 36 Days to CAT 2024 Test-10

Participants: 127

Take Free Test Here

Comments
 

Argha De

Hi, great article on excel automation. However, there are couple of things in the code which I would like to highlight in order to make it more generic. 1) The code assumes that there are only 3 rows of data (A2:A5). If any other row is automatically added, then the code would need to be changed again, which can be trouble some for people who are not conversant with programming. 2) The email sender sub routine is dealing with outlook only. If the user uses any other email app (mozilla thunderbird etc.), then the code might throw errors. Again changes has to be made programmatically. Resolutions: 1) Code: Dim sh as worksheet Dim n as integer set sh = ActiveWorkbook.ActiveSheet n=2 while sh.Range("A" & n) "" 'Prog logic n = n+1 wend 2) Use workbook.sendmail function: this is a generic method and can be used with any email app. However, options like CC, BCC or setting the body of the mail can not be done. For that outlook has to be used. But this can be useful for someone who is not using outlook. Syntax: ActiveWorkbook.Sendmail abc@gmail.com "Mail subject" if the requirement is to send the mail to multiple recipients at one go, then the mail ids can be stored in an array and the array can be used in sendmail. Hope this helps

15 Jun 2014, 06.15 PM

Argha De

A small correction: while sh.Range(“A” & n) ""

15 Jun 2014, 06.21 PM

Argha De

For some reason not-equality sign ( less than symbol followed by greater than symbol) is not getting printed in the comments. The while loop should be: while sh.Range(“A” & n) not-equality symbol “”

15 Jun 2014, 06.24 PM