vba - require loop for sending mail thru excel -


sub mail_activesheet() ' works in excel 2000, excel 2002, excel 2003, excel 2007, excel 2010, outlook 2000, outlook 2002, outlook 2003, outlook 2007, outlook 2010     dim sourcewb workbook     dim destwb workbook     dim cell range     dim subj string     dim emailaddr string     dim cc string     dim bcc string     dim body string     dim attment string     dim outapp object     dim outmail object     dim x string      x = range("b2").select     until activecell = ""     company = activecell     activecell.offset(0, 1).range("a1").select     = activecell     activecell.offset(0, 2).range("a1").select     cemail = activecell     activecell.offset(1, -3).range("a1").select     emailaddr = range("l2")     cc = range("m2")     bcc = range("n2")     subj = range("o2")     attment = range("p2")     body = "dear all," & vblf _     & vblf _     & "request present ecs per below details & pl confirm after submission of data file.  " & vblf _     & vblf _     & "cecs handover date                 :" & range("i2") & vblf _     & vblf _     & "settlement date                       :" & range("j2") & vblf _     & vblf _     & "number of records                    :" & range("f2") & vblf _     & vblf _     & "total contra amount                 : " & range("g2") & vblf _     & vblf _     & "type of presentation                  : ecs debit" & vblf _     & vblf _     & "attachments                              : e-2 form/validation reports/ecs data file" & vblf _     & vblf _     & "thanks & regards" & vblf _     & vblf _     & "gobi l" & vblf _     & "ing vysya bank ltd | cecs | 100, eden park | 20 vittal mallya road | bangalore-560001 | ph :080-22532127 | "      application         .screenupdating = false         .enableevents = false     end      set sourcewb = activeworkbook     set destwb = activeworkbook      set outapp = createobject("outlook.application")      set outmail = outapp.createitem(0)          outmail             .to = emailaddr             .cc = cc             .bcc = bcc             .subject = subj             .body = body             .attachments.add (attment)             .display         end         loop      set outmail = nothing     set outapp = nothing      application         .screenupdating = true         .enableevents = true     end  end sub 

please read , respect rules , take on link mehow provided.


as problem, have tried writing each recipient in column, looping through table , sending mail?

the table this:

                        b               c                 +---------------+---------------+---------------+--- ... 1 | r1@foo.bar    : r2@foo.bar    : r3@foo.bar    | 2 | cc1@bar.foo   : cc2@bar.foo   : cc3@bar.foo   | 3 | bcc1@far.boo  : bcc2@far.boo  :               |   +---------------+---------------+---------------+--- ... 4 | rr4@foo.bar   :               :               | 5 | cc4@bar.foo   : cc5@bar.foo   :               | 6 |               :               :               |   +---------------+---------------+---------------+--- ... 

where in first line can put recipients, in second ccs , in third bccs. , in 4th line stats on again recipients. have loop through table , send mail.


little hint on side: can use step 3 increase iterator 3 (instead of 1) after iteration.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -