ISSUE: Outlook Automation fails at [Outlook Application].Recipients.Add ("Jon Grande")
Error message:
Runtime Error 438: "Object does not support this property or method.
MS example: https://learn.microsoft.com/en-us/office/vba/api/Outlook.Recipients
Line that fails: Set MailRecip = App.Recipients.Add("Jon Grande")
Private Sub cmdEmail_Contact_Click()
Call TestOutlookIsOpen 'AUTHOR: Ron Debruin> https://www.rondebruin.nl/win/s1/outlook/openclose.htm
Call GetAppExePath("msaccess.exe") 'AUTHOR: Daniel Pineault, CARDA Consultants Inc.
' IsAppRunning ("Outlook.Application") 'https://www.devhut.net/createobjectoutlook-application-does-not-work-now-what/
' GetAppExePath("firefox.exe") 'AUTHOR: Daniel Pineault, CARDA Consultants Inc.
' GetAppExePath ("outlook.exe") 'AUTHOR: Daniel Pineault, CARDA Consultants Inc.
Dim App As Object 'Outlook.Application
Dim Mail As Object 'Outlook.MailItem
Dim MailRecip As Object 'Outlook.Recipient
Const olMailItem = 0
Set App = CreateObject("Outlook.application")
Set Mail = OutlookApp() '<<<<<<<<<<< See Sub Macro MyMacroThatUseOutlook in TestTheCode Module
With Mail
Set MailRecip = App.Recipients.Add("Jon Grande")
**Set MailRecip = App.Recipients.Add("Jon Grande")**
Set MailRecip = App.Recipients.Add("Graham Smithwick@yahoo.com")
MailRecip.Type = 1 'Designates the above is TO recipients
.Subject = "5105088005@tmomail.net"
.Body = "<a href='tel:19254511573'> To Call CaolePepe (925-451-1573)</a> "
For Each MailRecip In .Recipients
If Not MailRecip.Resolve Then
Mail.Display
End If
Next
.Send 'this sends the mail
End With
Set MailRecip = Nothing
Set Mail = Nothing
Set App = Nothing
End Sub