[AccessD] Outlook Automation

Daniel Waters df.waters at outlook.com
Thu Mar 21 18:48:19 CDT 2024


In https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem the way to set up an Outlook Item is

	Set myItem = Application.CreateItem(olMailItem)

	Your code is: 
	Set myItem = Application.CreateItem(0)	

Also:
.Recipients would be for display names:
Set myRecipient = myItem.Recipients.Add ("Jon Grande")

-----Original Message-----
From: AccessD <accessd-bounces+df.waters=outlook.com at databaseadvisors.com> On Behalf Of Rocky Smolin
Sent: 21 March, 2024 18:07
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Outlook Automation

Oops - forgot to add these two lines to my post:

    Set myolApp = CreateObject("Outlook.Application")
    Set myItem = myolApp.CreateItem(0)

Those are probably important :o)

Late Binding BTW.

Thanks

r

On Thu, Mar 21, 2024 at 4:04 PM Daniel Waters <df.waters at outlook.com> wrote:

> Hi Rocky,
>
> Have you set the variables to the Outlook App itself?  Look back in 
> the code you cribbed from to find those.
>
> HTH!
> Dan
>
> -----Original Message-----
> From: AccessD 
> <accessd-bounces+df.waters=outlook.com at databaseadvisors.com>
> On Behalf Of Rocky Smolin
> Sent: 21 March, 2024 17:52
> To: Access Developers discussion and problem solving < 
> accessd at databaseadvisors.com>
> Subject: [AccessD] Outlook Automation
>
> Dear List:
>
> I am trying to create an email through Automation using late binding 
> (in case the target machine does not have access loaded; I check for 
> that first and bail if no outlook).
>
> My DIMs:
>
> Dim myolApp As Object
> Dim myItem As Object
>
> Code:
> myItem.To = Me.fldTenantEmail
> myItem.cc = "Kathy.Klein at arensgroup.com"
> myItem.Subject = "Rent Increase Notice - " & Me.fldTenantCompany & " - 
> " & me.fldTenantAddress & ", " & Me.fldTenantSuiteNumber
>
> The lines for .Subject and .CC work but Myitem.To fails with Method 'To'
> of object '_MailItem' failed.
>
> Me.fldTenantEmail contains Armando at fallbrookirrigation.com
>
> If I substitute xx for Armando at fallbrookirrigation.com then it works. 
> I'm thinking it may have something to do with the special characters?
>
> But I have cribbed this code from another app that works.
>
> Any ideas?
>
> MTIA
>
> Rocky
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
AccessD mailing list
AccessD at databaseadvisors.com
https://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list