?
Solved

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

Posted on 2016-10-07
10
Medium Priority
?
1,309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 70

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
 
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 70

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Suggested Courses

762 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