Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Outlook 2010 rules run on mail sent from Excel VBA?

I have the following basic email code in an Excel VBA:

Dim OutAppUser      As Object  
Dim OutMailUser     As Object  
Set OutAppUser = CreateObject("Outlook.Application")  
Set OutMailUser = OutAppUser.CreateItem(0)  
With OutMailUser  
            .To = Range("Ctl_Req_Email").Value  
            .CC = ""  
            .BCC = ""  
            .Subject = TempFNUser  
            .ReadReceiptRequested = False  
            .Body = userEmailText  
            .Attachments.Add FullTempNameUser  
            .Send    'Use .Send or .Display  
End With  

The workbook with this macro is widely distributed but actual driving of the email macro is done by only a few and now the email address where this goes has changed. I have created an Outlook rule for "after I send the message" which add's a "CC" for the new email address as a means of redirecting the email externally. The rule works perfectly on manual test emails, but does not seem to act on the email sent from the Excel VBA code. Does something additional needs to be coded on the VBA code to send the email in order to allow rules to run?

like image 581
Eric Gillespie Avatar asked Nov 13 '22 16:11

Eric Gillespie


1 Answers

http://www.slipstick.com/outlook/email/choosing-the-folder-to-save-a-sent-message-in/

"VBA does not work on messages created with File, Send commands in other applications or the Send to command in Windows Explorer. Send to commands use Simple MAPI, which bypasses Outlook functionality."

Does not actually say Rules but you have seen Rules bypassed.

If you really want to use Rules, have Outlook open up Excel.

like image 104
niton Avatar answered Nov 15 '22 06:11

niton