i want to know how to schedule automatically a macro for outlook. I 've created one macro which extract the attached file from an email and store it in a folder. This macro is working very well when i execute it by clicking macro "execute".
But i want this macro execute automatically everyday for example at 08:30 before coming to my office.
Thank you
One way would be to use:
A vbs to automate Outlook. I've added sample vbscript
for saving an attachment from the first item in the Outlook inbox below. The main differences between the vbscript
and the equivalent vba
automated from an app such as Excel is that in vbscript you can't declare types explicitly (ie VBA's Dim strTest As String
is Dim StrTest
in vbscript
Use Windows task scheduler to schedule daily execution.
You will probably need Click Yes to suppress the 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With