How to add CC with Lotus Notes email in Excel VBA -


i have macro sends email recipients automatically excel vba, have different columns in excel file such "recipient email address" , "cc", macro retrieve data worksheet , format accordingly. need add "cc" field 2 email addresses email format , couldn't figure out how that, can me that?

here's how worksheet looks like: enter image description here

here's entire code macro:

sub send_unformatted_rangedata(i integer) dim nosession object, nodatabase object, nodocument object dim varecipient variant  dim rnbody range dim data dataobject dim rnggen range dim rngapp range dim rngspc range  y:  dim stsubject string stsubject = "change request " + (sheets("summary").cells(i, "aa").value) + (sheets("summary").cells(i, "ab").value) + (sheets("summary").cells(i, "ac").value) + (sheets("summary").cells(i, "ad").value) + (sheets("summary").cells(i, "ae").value) + (sheets("summary").cells(i, "af").value) + (sheets("summary").cells(i, "ag").value) + (sheets("summary").cells(i, "ah").value) + (sheets("summary").cells(i, "ai").value) 'const stmsg string = "data part of e-mail's body." 'const stprompt string = "please select range:"  'this 1 technique send e-mail many recipients larger 'number of recipients it's more convenient read recipient-list 'a range in workbook. varecipient = vba.array(sheets("summary").cells(i, "u").value, sheets("summary").cells(i, "v").value)  on error resume next 'set rnbody = application.inputbox(prompt:=stprompt, _      default:=selection.address, type:=8) 'the user canceled operation. 'if rnbody nothing exit sub set rnggen = nothing 'set rngapp = nothing 'set rngspc = nothing  set rnggen = sheets("general overview").range("a1:c30").specialcells(xlcelltypevisible) 'set rngapp = sheets("application").range("a1:e13").specialcells(xlcelltypevisible)  'set rngspc = sheets(sheets("summary").cells(i, "p").value).range(sheets("summary").cells(i, "q").value).specialcells(xlcelltypevisible) 'set rngspc = union(rngspc, sheets(sheets("summary").cells(i, "p").value).range(sheets("summary").cells(i, "r").value).specialcells(xlcelltypevisible))  on error goto 0  if rnggen nothing , rngapp nothing , rngspc nothing     msgbox "the selection not range or sheet protected. " & _            vbnewline & "please correct , try again.", vbokonly     exit sub end if   'instantiate lotus notes com's objects. set nosession = createobject("notes.notessession") set nodatabase = nosession.getdatabase("", "")  'make sure lotus notes open , available. if nodatabase.isopen = false nodatabase.openmail  'create document e-mail. set nodocument = nodatabase.createdocument  'copy selected range memory. 'the clipboard replaced multiple copies. 'rngapp.copy 'rngspc.copy rnggen.copy  'to able see email , manually send add below  'call ouidoc.save(true, false, false)  'createobject("notes.notesuiworkspace").editdocument true, ouidoc  'appactivate "> " & ouidoc.subject  'retrieve data copied range. set data = new dataobject data.getfromclipboard  'add data mainproperties of e-mail's document. nodocument   .form = "memo"   .sendto = varecipient    .subject = stsubject   'retrieve data clipboard.   .body = data.gettext & " " & stmsg   .savemessageonsend = true end  'send e-mail. 'changed xu ying make email being sent automatically manually      dim uimemo object     dim ws object     set ws = createobject("notes.notesuiworkspace")     nodocument.save true, true, false     set uimemo = ws.editdocument(true, nodocument)  'release objects memory. set nodocument = nothing set nodatabase = nothing set nosession = nothing   'activate excel user.  'appactivate "excel"  'empty clipboard. application.cutcopymode = false  = + 1 if sheets("summary").cells(i, "u").value <> "" goto y: end if  msgbox "the e-mail has been created , distributed.", vbinformation  end sub  sub send_formatted_range_data(i integer) dim oworkspace object, ouidoc object dim rnbody range dim lnretval long dim stto string  dim stsubject string const stmsg string = "an e-mail has been succesfully created , saved."  dim rnggen range dim rngapp range dim rngspc range  stto = sheets("summary").cells(i, "u").value  stsubject = "e-mail approval " + (sheets("summary").cells(i, "a").value) + "  project  " + replace(activeworkbook.name, ".xls", "")  'check if lotus notes open or not. lnretval = findwindow("notes", vbnullstring)  if lnretval = 0   msgbox "please make sure lotus notes open!", vbexclamation   exit sub end if  application.screenupdating = false  set rnggen = sheets("general overview").range("a1:c30").specialcells(xlcelltypevisible) set rngapp = sheets("application").range("a1:e13").specialcells(xlcelltypevisible)  set rngspc = sheets(sheets("summary").cells(i, "p").value).range(sheets("summary").cells(i, "q").value).specialcells(xlcelltypevisible) set rngspc = union(rngspc, sheets(sheets("summary").cells(i, "p").value).range(sheets("summary").cells(i, "r").value).specialcells(xlcelltypevisible)) on error goto 0  if rnggen nothing , rngapp nothing , rngspc nothing     msgbox "the selection not range or sheet protected. " & _            vbnewline & "please correct , try again.", vbokonly     exit sub end if  rnggen.copy rngapp.copy rngspc.copy  'instantiate lotus notes com's objects. set oworkspace = createobject("notes.notesuiworkspace")  on error resume next  set ouidoc = oworkspace.composedocument("", "mail\xldennis.nsf", "memo") on error goto 0  set ouidoc = oworkspace.currentdocument  'using lotusscript create e-mail. call ouidoc.fieldsettext("entersendto", stto) call ouidoc.fieldsettext("entercopyto", stcc) call ouidoc.fieldsettext("subject", stsubject)  'the can used if want add message created document. call ouidoc.fieldappendtext("body", vbnewline & stbody)  'here selected range pasted body of outgoing e-mail. call ouidoc.gotofield("body") call ouidoc.paste  'save created document. call ouidoc.save(true, false, false) 'if e-mail should sent add following line. 'call ouidoc.send(true)  'release objects memory. set oworkspace = nothing set ouidoc = nothing  application   .cutcopymode = false   .screenupdating = true end  msgbox stmsg, vbinformation  'activate lotus notes. appactivate ("notes") 'last edited feb 11, 2015 peter moncera  end sub 

here's way how solved own problem @siddharth rout

firstly, need add dim vacc variant , cell position of email addresses need cc:

vacc = vba.array(sheets("summary").cells(i, "aa").value, sheets("summary").cells(i, "ab").value, sheets("summary").cells(i, "ac").value) 

then add data mainproperties of e-mail's document:

with nodocument   .copyto = vacc end 

at last step, set dim copyto string

hope of in need.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -