hi
this code used to work in the past (open email form drive, filled send to and displayed email ), probably with older version of outlook, excel. now this code exits form sub at myRecipients.Add ws_names.Cells(i, 1)
thanks for any suggestions
this code used to work in the past (open email form drive, filled send to and displayed email ), probably with older version of outlook, excel. now this code exits form sub at myRecipients.Add ws_names.Cells(i, 1)
thanks for any suggestions
VBA Code:
Dim ws_names As Worksheet
Dim i, lr As Integer
Dim OutApp As Object
Dim OutMail As Object
Dim myRecipients, myCCs, myRecipient As Object
' setup
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate("C:\Analytics\Out_notes\ATP_send.oft") ' [B][U]<= seems that OutMail = "" leading to issues later[/U][/B]
Set myRecipients = OutMail.Recipients
Set myCCs = OutMail.Recipients
Set ws_names = ThisWorkbook.Sheets(1)
'add recipients
lr = ws_names.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lr
myRecipients.Add ws_names.Cells(i, 1) ' [B][U]<= at this point program exits sub[/U][/B]
Next
If Not myRecipients.ResolveAll Then
For Each myRecipient In myRecipients
If Not myRecipient.Resolved Then
MsgBox myRecipient.Name
End If
Next
End If