Scheduling a macro to run at a certain time

Just a quick one.

Is there any way to use outlook to run a macro at a specified time everyday/week/month or whatever I choose?

If so, some code snippets would be great also.  Bear in mind the macro will send an email and also contains a connection to a remote database.

Many thanks in advance

Matt Lindsay
LhXsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bruintjeCommented:
Hello LhXs,

1. use a vbs script to open outlook and send the email
2. schedule the script on the windows task scheduler for your interval

i think using vbs or even vba will result in the security problem > http://www.slipstick.com/outlook/esecup.htm

so i would advise to use vbsendmail from vb script > http://www.freevbcode.com/ShowCode.Asp?ID=109
and schedule the script

hope this helps a bit
bruintje
0
David LeeCommented:
Greetings, LhXs.

Yes, you can schedule a macro to run via task item and a little code.  Here's are examples from a couple of question I participated in where I did something very much like what you appear to want:

http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21372956.html
http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21450551.html 

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey Kane - TechSoEasyPrincipal ConsultantCommented:
As with all Office programs, Outlook has a built-in Visual Basic editor which is accessed via Tools > Macro >

It does take some Visual Basic know-how to do this, but it's entirely possible.

There is a brief overview about automating tasks in Outlook here:
http://office.microsoft.com/en-us/assistance/CH063566791033.aspx

If you want more detailed information and assistance, please see:
http://www.outlookcode.com  This site is owned and run by Sue Mosher, who also operates slipstick.com.  She's THE Microsoft Outlook MVP.

Jeff
TechSoEasy
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

LhXsAuthor Commented:
I think BlueDevilFan has the best handle on my question so far (Thanks, I think you may have solved one of my previous posts).
The first of those links helps the best, but it's quite a convoluted solution.  I was wondering:

Why isnt there an Application.ontime event for VBA in Outlook like these is in excel or other office apps?

Also; How to get around the security warnings it keeps throwing up?

I really can't understand how Microsoft have missed a boat in outlook by providing the facility to script (VBA) and schedule (calander) but not let you launch apps or scripts from an appointment?

Any further answers or solutions?

Many thanks for you help

Matt
0
David LeeCommented:
> Why isnt there an Application.ontime event for VBA in Outlook like these is in excel or other office apps?
Sorry, Microsoft doesn't consult with me on their design decisions, so I can't answer the question.

> Also; How to get around the security warnings it keeps throwing up?
There are three ways to do this, two of which require third-party software.  One, write an Outlook add-in.  Add-ins have different security constraints.  Two, use ClickYes, a utility that clicks the Yes button when the security dialog pops up.  Three, use Outlook Redemption, a COM component that sidesteps Outlook security.

> but not let you launch apps or scripts from an appointment
You can launch an app or script.  If the script is internal to Outlook, then simply make a call to it.  If the script is external or if you want to launch a separate app, then you have to shell out and run it.
0
LhXsAuthor Commented:
"> but not let you launch apps or scripts from an appointment
You can launch an app or script.  If the script is internal to Outlook, then simply make a call to it.  If the script is external or if you want to launch a separate app, then you have to shell out and run it."

How do I make a call to my macro from the appointment scheduler form? This is really what I am after, this would solve my problem right off the bat.

Thanks for the continued help.

Matt

p.s. I can't beleive M$ doesnt consult you? How rude!!!
0
bruintjeCommented:
as said you can write a vbs script using sendmail on the windows task scheduler this will prevent any security warning and enable you to run the task in the background on schedule
0
bruintjeCommented:
disregard my last post :)
0
David LeeCommented:
> I can't beleive M$ doesnt consult you? How rude!!!
I agree!  I've written Bill, but no response yet.

In the code from the two questions I linked to there's a procedure called ReminderFire.  To fire your own macro you just need to put a call to it in that procedure.  Something like this:

Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
    'Is the reminder for a task
    If ReminderObject.Item.Class = olAppointment Then
        Set objItem = ReminderObject.Item
        'Is the reminder for our task
        If objItem.Subject = "Run MyProcess" Then
            MyProcedureNameGoesHere
            objItem.ReminderTime = DateAdd("h", 1, Now)
            objItem.Save
        End If
    End If
    Set objTaskItem = Nothing
End Sub
0
Jeffrey Kane - TechSoEasyPrincipal ConsultantCommented:
FYI, I was curious about Application.OnTime not being in Outlook, and came upon this code sample:
http://www.theofficeexperts.com/forum/showthread.php?t=5322

Jeff
TechSoEasy
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.