Creating E-mail in VBScript

  • Thread starter Tom Ha via OfficeKB.com
  • Start date
T

Tom Ha via OfficeKB.com

Hello, I have this code in outlook to send 2 emails 1 minute apart from
each other:

Sub ServerTestingMacro()
'Macro Name will show as ServerTestingMacro

'Create 1st email to start escalation and send it
Set objNewEmail = Application.CreateItem(olMailItem)
With objNewEmail
.Subject = ""
.Body = ""
.To = "(e-mail address removed)"
.Send
End With
Set objNewMail = Nothing

'Wait a minute
lngTimeStart = Timer()
Do
'The DoEvents line prevents Outlook from locking up for the minute
DoEvents
lngTimeStop = Timer()
If (lngTimeStop - lngTimeStart) > 60 Then Exit Do
Loop

'Create 2nd email to acknowledge escalation and send it
Set objNewEmail = Application.CreateItem(olMailItem)
With objNewEmail
.Subject = ""
.Body = ""
.To = "(e-mail address removed)"
.Send
End With
Set objNewMail = Nothing
End Sub

This works all very well in outlook as long as I run the macro everyday
manually.

What I was wanting help on was if its possible to do this in VBScript so I
can use MS scheduler to run this everyday at 8am, or is there a way in
Outlook 2003 to do this everyday?

If this was in VBScript, I could use MS scheduler and simply run it from
there?

Basically I want to be able to send 2 emails 1 minute apart at 8am everyday
automatically.

Any help is muchly appreciated.
 
S

Sue Mosher [MVP-Outlook]

You could create a recurring task with a reminder, then run your macro from the Application_Reminder event handler.
 
R

Robert Morley

Another thing you might want to consider is to use Exchange Server's
scheduling features to send your e-mail. Obviously this will only work if
you're using Exchange Server, plus you also need to have your mailbox on the
server (or if the mailbox is local, then your computer needs to be on and
running Outlook at the time) and you need to know what the content of your
e-mails will be in advance. So if you're generating a daily report, for
example, this might not be the ideal solution.

Through the GUI, you can get to this via View, Options, then check off the
"Do not deliver before" box and fill in the date & time. I don't know the
property name to access this off-hand, but if this would work for you, ask
and I'm sure someone like Sue will be able to help.



Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top