PC Review


Reply
Thread Tools Rate Thread

Creating E-mail in VBScript

 
 
Tom Ha via OfficeKB.com
Guest
Posts: n/a
 
      2nd Jun 2005
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 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 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.
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      3rd Jun 2005
You could create a recurring task with a reminder, then run your macro from the Application_Reminder event handler.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Tom Ha via OfficeKB.com" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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 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 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.

 
Reply With Quote
 
Robert Morley
Guest
Posts: n/a
 
      3rd Jun 2005
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

"Tom Ha via OfficeKB.com" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 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 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Task with VBScript yannickestrada Microsoft Outlook VBA Programming 14 28th Jul 2009 06:47 PM
Creating VB.Net COM component to use in VBScript. Wake-Up-Jeff Microsoft VB .NET 6 29th Oct 2007 03:13 PM
Creating Computer accounts in the AD with VBScript Greg K Wong Microsoft Windows 2000 Active Directory 3 9th Jan 2005 01:07 AM
Creating AD objects with VBScript Örjan Johansson Microsoft Windows 2000 Active Directory 1 28th Apr 2004 03:23 PM
Creating VBScript Components for Use As COMAddins Hamilton Microsoft Excel Programming 1 15th Mar 2004 03:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:43 PM.