Hi all,
I can make the below subroutine work if I declare olMailItem as Variant. But, as I understand it (and my understanding is somewhat limited - I'm new to VBA), Variant is a sort of wildcard. Can anyone tell me what it specifically should be?
I've tried Outlook.MailItem but that gives me a "User-defined type not defined" error.
I can make the below subroutine work if I declare olMailItem as Variant. But, as I understand it (and my understanding is somewhat limited - I'm new to VBA), Variant is a sort of wildcard. Can anyone tell me what it specifically should be?
I've tried Outlook.MailItem but that gives me a "User-defined type not defined" error.
Code:
Option Explicit
Sub testEmail()
Dim myOutlook As Object
Dim myMailItem As Object
Set myOutlook = CreateObject("Outlook.Application")
Set myMailItem = myOutlook.CreateItem(olMailItem)
myMailItem.Display
Set myMailItem = Nothing
Set myOutlook = Nothing
End Sub