Moustafa Houssien
New Member
- Joined
- Jul 7, 2023
- Messages
- 5
Hi,
I need support for knowing the problem in the below code as the error message "Run-Time Error '13':type mismatched" appeared
Sub SendAllDraftEmails()
'Declare variables
Dim objOutlook As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Dim lCounter As Long
'Get the Outlook application object
Set objOutlook = Application
'Get the draft folder
Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
'Initialize the counter
lCounter = 1
'Loop through all the items in the draft folder
For Each objMail In objFolder.Items
'Send the email
objMail.Send
'Increment the counter
lCounter = lCounter + 1
Next objMail
'Display a message box
MsgBox "Sent " & lCounter & " emails"
End Sub
I need support for knowing the problem in the below code as the error message "Run-Time Error '13':type mismatched" appeared
Sub SendAllDraftEmails()
'Declare variables
Dim objOutlook As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Dim lCounter As Long
'Get the Outlook application object
Set objOutlook = Application
'Get the draft folder
Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
'Initialize the counter
lCounter = 1
'Loop through all the items in the draft folder
For Each objMail In objFolder.Items
'Send the email
objMail.Send
'Increment the counter
lCounter = lCounter + 1
Next objMail
'Display a message box
MsgBox "Sent " & lCounter & " emails"
End Sub