How to automatically plan a macro in Outlook?

I want to know how to automatically plan macros for Outlook. I created one macro that extracts the attached file from email and saves it in a folder. This macro works very well when I execute it by clicking the run macro.

But I want this macro to run automatically every day, for example, at 08:30, before coming to my office.

thanks

+4
source share
2 answers

One way would be to use:

  1. to automate Outlook. I added a vbscript sample to save the attachment from the first item in the Outlook inbox below. The main difference between vbscript and similar vba automated from an application such as Excel is that you cannot explicitly declare types in vbscript (i.e. VBA Dim strTest As String is Dim StrTest in vbscript

  2. ) .Use the Windows Task Scheduler to schedule daily execution.

  3. You will probably need to click Yes to disable Outlook security messages.

     Dim objApp Dim olNs Dim olInbox Dim olMsg Dim olAtt On Error Resume Next Set objApp = CreateObject("Outlook.application") Set olNs = objApp.GetNamespace("MAPI") Set olInbox = olNs.getdefaultfolder(6) Set olMsg = olInbox.items(1) If olMsg.attachments.Count > 0 Then Set olAtt = olMsg.attachments(1) olAtt.SaveAsFile "c:\temp\" & olAtt.Filename End If objApp.Quit Set objApp = Nothing 
+1
source

I have a similar problem. I have a script to upload an attachment to hdisk and run this script by setting the rule in outlook. However, our IT service has an activated ATP protocol that scans attachments, and the script downloads irrelevant data instead of the actual file attached. So I decided to run the scheduled script instead. So that by the time the script starts, the attachment has already been scanned.

Have you already found any solution?

0
source

Source: https://habr.com/ru/post/1390717/


All Articles