Tuesday 15 April 2014

Outlook VBA: Script not triggering on email receive when computer is locked -


I have a VB script running on my Outlook session that looks at every new email and when a specific email address and Receiving the subject, it then saves attachments from that email and runs a best macro to run.

When I test it (by sending an email to another email address) It works fine This morning, my computer received an email (but the computer was "locked", Windows 7), but the script Was not started. I know that VBA should work in the background, even if the computer is "locked", then I am confused why this script was not triggered.

Does not my VBA script run continuously in the background whether the computer is locked or not?

Here is the code:

trigger the macro "go" when you receive an email from example@example.com subject = Today 0) then strMailItemID = Strings.Mid (EntryIDCollection, intMsgIDStart, (intMsgIDEnd - intMsgID) Start)) Other strMailItemID = EntryIDCollection end if Cont = ha NdleMessage (strMailItemID) intMsgIDStart = intMsgIDEnd + 1 intMsgIDEind = InStr (intMsgIDStart, EntryIDCollection, ",") loop while intMsgIDEnd & lt; & Gt; 0 and end-end sub-function handle message (string as strMailItemID) 'This function takes the e-mail id and determines whether this is our value sheet email' If so, then this is a common name, pricing. Xls' will be saved in the folder, in the end, it will call the Xcel Macro (at error) resume the next slow mail item Outlook as Outlook.mailItem slow path string resulted in the results Boolean results = true Set Mail ITEM = App Satrkgetaitimfrumid (StrMailItemID) if (mail Itamksender e-Meladder = "Example@examplekcom" and Stringskmid (mail Itam. Shuku, 1, 5) = "Today") and PATH = "C: \ "path \ pricing.itx" mailItem.Attachments.item (1) .SaveAsFile path calls runExcelMacro ( "C: \ path \ Auto.xlsm", "go") result = false end If handleMessage = result end function public function runExcelMacro (String as a string, as a string in the form of a string) 'This function starts as Macro Deum XL object set XL xl = CreateObject ("Excel.Ap plication ") xl.Workbooks.Open (path) 'xl.Visible = False xl.Run macroName Close xl.ActiveWorkbook (True) xl.Quit Set xl = Nothing End Function

Maybe I need to use a different setting for VBA to always run in the background?

Thank you, and sorry that my question is not as well defined as I'd like - I still have it Do not know what is wrong!

Cheers,

Zack

Event removed When a new item is received in the Inbox, MSDN tells about this event:

But for users with Exchange Server accounts (Non-Cached Exchange Mode or Cached Exchange Mode) The event will only set a fire for messages which will be in the future when the server is started after Outlook. Events will not fire for messages that are synchronized in cached exchange mode immediately after Outlook Express. Es, and not already on the server for the same message when you start Outlook in non-Cached Exchange Mode.

A new message arrives in the Inbox when the new MailX event is on fire and before customer rule processing. You can use the entry ID given in the EntryIDCollection array to call the NameSpace.GetItemFromID method and to process the items. Use this method with caution to reduce the effect on the Outlook method.

Anyway, if I suggest making a rule instead, then you can provide a VBA sub for a rule. The VBA should look like the following:

  Public Sub-Test (mail as mailitem) 'Whatever you need end end  

There the mail object represents the coming out Outlook item as you can see that using the GetItemFromId method does not need to get the incoming email items programmatically. Besides, I suggest you choose another drive to save attachments in addition to

  path = "C: \ path \ pricing.xls"  

In the recent OS, C: Need Administrator privileges to write the drive.


No comments:

Post a Comment