Excel 2013 VBA - setting up a list of email reciepients (TO and CC) populating Oulook email -
i have set userform saves data incident details data sheet , saves data temporarily worksheet called 'email form' , laid out form 'email form' copied body of ms outlook email.
this works perfectly, , current coding provided sends 1 email to 1 recipient , cc'd another, need send same email multiple recipients. have created sheet called ‘email recipient list (same workbook) because want easy update lists required (none of users able edit hardcode in vba). column has list of recipients , column b has list of cc recipients.
i have searched , view several videos , sites, have been unable workout how extract respective lists ‘email recipient list’ sheet , populate outlook email without affecting existing actions. don't want macro button users click because code opens outlook email.
this existing code:
sub log_send_reset() 'this opens outlook details of form 'works "email form" dim secincno string 'this bit emails current worksheet in body of email html '#if 0 dim rng range dim outapp object dim outmail object set rng = nothing on error resume next set rng = sheets("email form").range("a1:ab119") on error goto 0 application .enableevents = false .screenupdating = true 'shybutterfly set true (it false) end set outapp = createobject("outlook.application") set outmail = outapp.createitem(0) on error resume next outmail 'this bit tells send email to, subject line etc .to = "246abc@company.com" .cc = "rep3@company2.com" .bcc = "" .subject = range("h6").value & " - " & "sac" & range("g12").value & " - " & range("g14").value & " - " & range("h8").value .htmlbody = rangetohtml(rng) 'shybutterfly changed from.send .display see .display 'or use .display if want edit / add text before sending end on error goto 0 application .enableevents = true .screenupdating = true end set outmail = nothing set outapp = nothing thisworkbook.save 'thisworkbook.close 'application.quit end sub
i'd appreciate assistance.
either call mailitem.recipients.add
each recipient (it returns recipient object, sets recipient.type
property olto/olcc/olbcc appropriately) set to/cc/bcc properties ";" separated list of addresses.
Comments
Post a Comment