PDA

View Full Version : [SOLVED:] Rules - Start Application After Sending Email



rgiljohann
03-27-2014, 06:16 AM
My outlook sends an email at a certain time each morning. I need a way to start a new file after sending that first message each morning. In Rules, there is an easy way to do this after receiving an email through start application, but there is no option to start an application after sending an email.

Please note, the message stays in the outbox for two minutes before being sent, I would hope that the file or application starts after it is actually sent. Any ideas?

westconn1
03-27-2014, 01:37 PM
you can use the itemsend event to run code when a message is sent, the code can monitor the outbox folder to make sure the item has been sent

rgiljohann
03-27-2014, 01:48 PM
I am still so new with vba... I do not know the syntax at all.

I am guessing it would be something with an If :
If (itemsend syntax) = sent
then start excel application

Am I in the right ballpark?

westconn1
03-28-2014, 02:27 AM
close but no cigar

try like

Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)
Dim mi As MailItem, mybcc As Recipient, ob As Items
If item.Subject = mycriteria Then ' match some criteria to subject or other, so not all emails will open excel
Set ob = GetNamespace("mapi").GetDefaultFolder(olFolderOutbox).Items
Do While ob.Count > 0 ' wait till outbox is empty
DoEvents
Loop
Set xl = CreateObject("excel.application")
xl.Visible = True
'leave visible for user, or open appropriate workbook, what ever
End If
end sub