WATPI Prep
XAT/ OMET
Interview Experiences
Admissions
Upskill
Placements
RTI Response
Rankings
Score Vs. %ile
Salaries

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

WAT 2025- Should OTT and YT be censored?

Participants: 31

WAT 2025: Mahakumbh

Participants: 43
HUL FS Quiz Ad
WATPI S05 Quiz Ad

WAT 2025: ChatGPT vs. DeepSeek

Participants: 44

NMIMS Competency Test 10 (Updated)

Participants: 390

NMIMS Competency Test 9 (Updated)

Participants: 282

NMIMS Competency Test 8 (Updated)

Participants: 250

NMIMS Competency Test 7 (Updated)

Participants: 240

NMIMS Competency Test 6 (Updated)

Participants: 257

NMIMS Competency Test 5 (Updated)

Participants: 322

NMIMS Competency Test 4 (Updated)

Participants: 364

NMIMS Competency Test 3 (Updated)

Participants: 456

NMIMS Competency Test 2 (Updated)

Participants: 704

NMIMS Competency Test 1 (Updated)

Participants: 1036

DILR 2022 - Test 19

Participants: 7

QA 2022 - Test 19

Participants: 9

VARC 2022 - Test 20

Participants: 20

VARC 2022 - Test 21

Participants: 16

QA 2022 - Test 20

Participants: 8

DILR - Trail

Participants: 0

CMAT 2022

Participants: 23

CMAT 2018 SLOT 2

Participants: 2

CMAT 2018 SLOT 1

Participants: 8

CMAT 2019 SLOT 1

Participants: 10

CMAT 2020 SLOT 1

Participants: 1

CMAT 2021 SLOT 2

Participants: 14

CMAT 2021 SLOT 1

Participants: 21

CMAT 2023 SLOT 2

Participants: 28

CMAT 2023 SLOT 1

Participants: 47

CMAT 2024 SLOT 2

Participants: 55

CMAT 2024 SLOT 1

Participants: 59

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