Thank you for your replies,
I ended up combining the two codes together, sending a copy of the sheet and the CDO code. It works fine but there is a slight problem here. When a mail is sent out, i enclose an attachment to it. The problem here is the first person gets one attachment file, the second person gets two attachment files, the 3rd gets 3 attachment files. This is not right. It keeps on appending the previous to the current one. That's why it keeps on adding depending on the number of people to be sent to. What's right is each persons should get only one attachment file. There is something wrong in the code i may have overlooked.
Here is the code
For N = 0 To i - 1
TempFileName = "mysheet " & Format(Now, "dd-mmm-yy h-mm-ss")
ThisWorkbook.Sheets("mysheet").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormatNum
.Sheets("mysheet").Range("B3") = mystaff(N)
.Sheets("mysheet").Range("E3") = Format(Now, "dd-mmm-yy")
.Close SaveChanges:=True
End With
myattach(j) = TempFilePath & TempFileName & FileExtStr
With iMsg
Set .Configuration = iConf
.To = Addr(N)
.CC = ""
.BCC = ""
.From = """Admin Staff"" <[email protected]>"
.Subject = "mysheet for beginning week " & Format(Now, "dd-mmm-yy")
.TextBody = strbody
.AddAttachment myattach(j)
.Send
End With
Kill TempFilePath & TempFileName & FileExtStr
j = j + 1
I even tried to store the filename into the array, myattach but to no avail.
wonder what i have done wrong here.
Thank you in advance
Bookmarks