Hi all,

Firstly, I'm VERY new to VBA, so I'm sure this will be an irritatingly simple request...

Ive designed a macro within Excel to write a batch of emails and save them in my Outlook drafts folder. I then have a Macro in Outlook to send all items in my drafts folder. This I had all working fine. Whilst testing I got an error message when one of the 'Aliases' used to send the emails to didnt match the entry in the global address book. To combat this I've been trying to add in a resolve function, however I cant get my macro to work - I keep getting a 'invalid next control variable reference error'. I've pasted my code below:


Option Explicit
Public Sub SendDrafts()
Dim lDraftItem As Long
Dim myOutlook As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim myDraftsFolder As Outlook.MAPIFolder
Dim myRecipient As Outlook.Recipient
Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders
Set myDraftsFolder = myFolders("Mailbox - Kenney, David").Folders("Drafts")
For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1
If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To)) > 0 Then
For Each myRecipient In myDraftsFolder.Items.Item(lDraftItem).To
myRecipient.Resolve
If myRecipient.Resolved Then
myDraftsFolder.Items.Item(lDraftItem).Send
End If
Next lDraftItem
Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing
End Sub


Hope you can help!