VBA new mail event

Lavina

Board Regular
Joined
Dec 18, 2018
Messages
75
Hello guys,

I'm trying to replace people at my work and the next step is running specific macros when certain emails are received.

I am using office 365, and I'm not sure what is going wrong.

I found multiple examples, but none of them seem to work, an example: https://docs.microsoft.com/en-us/office/vba/api/outlook.application.newmail

But once run i get the compile error: user-defined type not defined

The error seems to originate from:

Public WithEvents myOlApp As Outlook.Application

and I have no practice with working with applications that are outside excel, any help is much appreciated!


https://www.tachytelic.net/2017/10/how-to-run-a-vba-macro-when-new-mail-is-received-in-outlook/
This would get me all the info i need, but i cannot get it to work either, really not sure what im missing
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Sounds like you need to load the Outlook References.

in VB, click on Tools > References. Scroll down and select the Microsoft Outlook XX.0 Object Library.


 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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