Excel VBA generate email to M365 Outlook

drag1c

Board Regular
Joined
Aug 7, 2019
Messages
108
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi,

I've tried test code below those images, to generate email via M365 Outlook.
So, both Excel and Outlook are in the same package M365 64-bit and this is their interface:
1743507196622.png

1743507223337.png

So, this looks pretty new to me and it's not Web based. This is application installed on my company PC. In past we were using Office 2016 32-bit package.

I have this library activated:
1743507319519.png


And this is my test code:
VBA Code:
Sub TestOutlook()
    Dim objOutlook As Object
    Dim objMail As Object


    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)

    With objMail
        .To = "your_email@example.com"
        .Subject = "Test Email"
        .body = "This is a test email."
        .display
    End With

    Set objMail = Nothing
    Set objOutlook = Nothing
End Sub

It gives error:
1743507401938.png

Automation error. The specified module could not be found.

Crash happens in this row:
VBA Code:
Set objOutlook = CreateObject("Outlook.Application")

Does anyone have idea what is problem here?
 
Download Classic Version of Outlook :

 
Upvote 0
1743758729367.png


This is pretty strange. It is classic version but I can't hook COM Object.

Anyway, we can close this topic. If classic is going to disappear, I need permanent solution, not temporary.
I've achieved something via shell, but it doesn't allow me to use html tags. Just plain text...

Thank you all.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top