PDA

View Full Version : outlook - sending e-mail at a certain time



PaulCorbett
02-09-2005, 10:07 AM
Hi

Can anybody help me?

I need to get outlook to check if its received certain messages at a certain
time and then e-mail the people whe havn't sent in their messages
to remind them.

I can just about cope with the programming for the checking and sending part
but how do I get the macro to run at a certain time?

Any help much appreciated

Killian
02-10-2005, 09:53 AM
Hi,
just some vague thoughts on this I'm afraid...
You'll need an event that fires at a certain time to trigger the macro and a reminder of some kind would do it. I'm not sure how to set a reference to a reminder object or how you could use it to trigger your code - I'll have a look at that tomorrow.

But is it not enough to set the emails you send out with message flags set with your deadline?

Killian
02-11-2005, 04:02 AM
OK, I've had a look at this now. There is an application event for reminders which I just used by adding a new task with the subject: "TEST" and setting a reminder.

In the VBE, select 'Application' in the object dropdown and 'Reminder' from the events and add this code
Private Sub Application_Reminder(ByVal Item As Object)

If Item.Subject = "TEST" Then MsgBox "The Application_Reminder event just fired."

End Sub

This worked nicely, so you'll be able to set a recurring task that fires you code at a regular time each day/week/month or have the option of setting one up whenever you like - any reminder will fire the code if it's item's subject value matches

Enjoy :-)

PaulCorbett
02-11-2005, 08:39 AM
Many thanks

That bit works fine.

But how do you get past the Outlook security message alerting you that VBA is trying to send a message. You have to press yes to get it to send the message, but I want it all to work automatically

Killian
02-11-2005, 09:29 AM
Good question... I can't get that message to show up by using code to send a mail item and I can't see where it's set in the options or object model.
I think this is something to do with the Object Model Guard implemented in Outlook 2002 and enhanced in 2003 which is designed to prevent malicious code hijacking Outlook and writing and sending emails.
It should not be coming up for local VBA code from the ThisOutlookSession module provided all your objects (specifically your MailItem) have been derived from the Application object so you may want to check all your object references comply with this.

Other than that, you may find more info at this very useful site:
http://www.outlookcode.com/

Have a good weekend
K :-)