Hello,
I am putting together a looping code that that will go down a list of emails in Excel and compose an email automatically, pulling a set of information from another set of cells per user on a monthly basis (the data in these cells will change).
The code I found to utilize will only let me pull in from one column to maintain the loop, but I need to pull in from multiple columns to compose the email.
Code:
VB:
Sub Preview()
I = Cells(2, "B").Value ' dynamising startrownumber to user fed value at cell B2
Do ' start the action ,buddy!!!!
Subj = Cells(I, "A").Value
Filepath = Cells(I, "B").Value
EmailTo = Cells(I, "C").Value
CCto = Cells(I, "D").Value
msg = Cells(I, "E").Value 'I THINK THIS IS WHERE AM HAVING TROUBLE. WILL ONLY PULL FROM COLUMN E.
Application.DisplayAlerts = False ' hey macro ,i dont wanna make you take time ,so this command to save time to avoid displays
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = EmailTo
.CC = CCto
.BCC = ""
.Subject = Subj
.body = msg
.Attachments.Add Filepath
.display
End With
On Error Goto 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
I = I + 1
Cells(1, "A").Value = "Outlook sent Time,Dynamic msg preview count =" & I - 3
Loop Until Cells(I, "C").Value = "0"
End Sub
Is there a better way to pull this information in? Basically I have the body of the email typed into the one cell in this column, but this does not allow me to pull in the individual set of data each month in a usable format.
Thank you!!!!
-Kevin
Bookmarks