Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2023, 11:59 AM
BilboBaggins BilboBaggins is offline How to use Outlook's 'Add_Item' Event to Send an Email Windows 10 How to use Outlook's 'Add_Item' Event to Send an Email Office 2013
Novice
How to use Outlook's 'Add_Item' Event to Send an Email
 
Join Date: Aug 2023
Posts: 1
BilboBaggins is on a distinguished road
Default How to use Outlook's 'Add_Item' Event to Send an Email

I have a scenario where I need to have an Add_Item event for a specific (non-default) folder in the current Outlook session.



The scenario is that an email is created by code running in Excel.
I have this code working fine.

The email is saved, by code, in a specific folder in the current Outlook profile in an Exchange environment.

I need to add some code (presumably to the "ThisOutlookSession" module) that will detect when the 'EmailItem' is saved to the folder ('Add_Item' Event?), and automatically send the email.

I've done quite a bit of reading and testing and can't seem to even trigger the event, much less send the email(s).
The be fair though, if I could just trigger the event, I'm sure I could send the email.
I'm no stranger to Outlook VBA but this event is eluding me.

Here's the current incarnation of the code I'm trying to use...

Code:
Public Sub Initialize_handler()
Dim myOlItems As Outlook.items

     Set myOlItems = Application.GetNamespace("MAPI") _
                             .Stores("redacted_alias@outlook.com") _
                             .GetRootFolder _
                             .folders("TestingAutoSend") _
                             .items

End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Outlook.MailItem)

     MsgBox "myOlItems_ItemAdd"

     Item.Send

End Sub
The code lives in the "ThisOutlookSession" module.

Macros are enabled.

The emails are minimally ready to send:
  • They contain a "To:" address
  • They contain a "Cc:" address
  • They contain a subject.
  • They have some message body.

I've read that I need to run the sub 'Initialize_handler' in order for the event to be detected and when I run it, it runs without error.

There are no errors when I drop a draft email in the folder.

The msgbox does not fire when I drop a draft email in the folder.

Please help me sort out this conundrum...
Thanks in advance!
Reply With Quote
Reply

Tags
mailitem, on event, outlook 2013



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Outlook's 'Add_Item' Event to Send an Email Prevent Outlook 2016 from Send/Receive Email when opening Outlook lcolson Outlook 1 10-17-2015 04:58 AM
Email reminder of an event in outlook calendar sam2149 Outlook 0 03-03-2015 05:00 AM
Outlook will not send email yourforester Outlook 1 10-04-2013 05:55 AM
outlook won't send email with attachments JB-1956 Outlook 1 11-24-2012 01:09 PM
How to use Outlook's 'Add_Item' Event to Send an Email outlook attachments zip when send event occure chriskaza81 Outlook 1 11-17-2010 08:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft