![]() |
|
#1
|
|||
|
|||
|
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
Macros are enabled. The emails are minimally ready to send:
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! |
|
| Tags |
| mailitem, on event, outlook 2013 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
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 |
outlook attachments zip when send event occure
|
chriskaza81 | Outlook | 1 | 11-17-2010 08:27 PM |