Solved

Schedule Macro Modules to Run Daily at Specific times (Outlook 2010)

Posted on 2016-10-07
10
73 Views
Last Modified: 2016-10-09
Hello,

I have created 9 modules using VBA in outlook.  They send a different email when executed.  I just need to know if I can scheduled them to run daily at specific times.

Attached is a screenshot for one of those modules.screenshot for one of those modules
Thanks for your help.
0
Comment
Question by:JParra72
  • 4
  • 3
  • 2
10 Comments
 

Author Comment

by:JParra72
ID: 41834306
Outlook will be already open at the time the macros run.
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 41834328
If you can modify the code from VBA to VBScript, and save each procedure as a .vbs file, you should be able to run them from the Windows Scheduler.  As I recall (it has been a while since I made any VBScript files), you can't declare objects as specific data types, or use most named constants (replace olMailItem with the numeric value, 0), but otherwise I think your code would work.
0
 

Author Comment

by:JParra72
ID: 41834337
How can I modify from VBA to VBScript?  by the way what was that first reply from Calle Peter?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41835149
Instead of rewriting your code, it might be easier to write PowerShell or VB Script code to trigger the Outlook VBA modules from a scheduled task.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 41835151
To modify the code, remove the declarations as specific data types, and replace the olMailItem named constant with 0 (its numeric value).  Save each procedure as a .vbs file, and try to run them.  There may be more changes needed.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 41835155
Another possible alternative is to use repeating tasks, which would trigger creation of emails when they fire.  I have done this, but it takes a lot of programming.  Here is some Access VBA that creates a single task item:
         'Create task item for sending the mail message later
         Set tsk = pappOutlook.CreateItem(olTaskItem)
         strMessage = "When the task reminder fires, an email message will " _
            & "be created and placed in the Outbox to be sent"
         With tsk
            .Display
            .Subject = strTaskSubject
            .DueDate = dteSend
            .StartDate = dteSend
            .Categories = "Reminder"
            .Body = strMessage
            
            'Store info for mail message in unused Task fields
            .BillingInformation = strToEMail
            .CardData = strMessageSubject
            .Mileage = strBody
            
            'Set task reminder for date when message should be sent
            .ReminderSet = True
            .ReminderTime = dteSend
            '.Display
            .Close (olSave)
         End With

Open in new window


and here is an event procedure for the ThisOutlookSession module, that creates the emails when the reminders fire:

Private Sub Application_Reminder(ByVal Item As Object)
'Created by Helen Feddema 1-30-2003
'Last modified 4-1-2004

On Error GoTo ErrorHandler
   
   Dim msg As Outlook.MailItem
   
   If Item.Categories = "Reminder" Then
      Set msg = Application.CreateItem(olMailItem)
      With msg
         msg.To = Item.BillingInformation
         msg.Subject = Item.CardData
         msg.Body = Item.Mileage
         msg.Send
      End With
   End If
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & _
      Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 41835158
BillingInformation, CardData and Mileage are built-in properties that don't display on the standard form.  They are very handy for storing miscellaneous data without the need for creating a custom form.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41835740
Forget my comment above. Outlook does not allow to run macros from outside it anymore, obviously for security reasons ...
I hate having to provide a reference to StackOverflow, but this VBA code shows a way to use the OS timer to directly call a specific sub. This needs a similar amount of code as the reminder approach, but is more direct and does not have to "misuse" mileage etc. properties.
0
 

Assisted Solution

by:JParra72
JParra72 earned 0 total points
ID: 41835980
Hello,

I appreciate the help and input from everyone.  I have accomplished what  I needed by creating a VBScript and scheduling it to run daily in the Windows scheduler.

Here is the script:

'Send email with phone report

Set objOutlook = CreateObject("Outlook.Application")
   Set objMail = objOutlook.CreateItem(0)

          objMail.to = "email@tosendto.com"
          objMail.Subject  = "3pm Summary Phone Report"
          objMail.Attachments.Add("C:\Phone Report\3pm_phone_report.pdf")
          objMail.Body = "Phone Calls, Inbound and Outbound Calls until 3pm"
          objMail.Send

Open in new window

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now