I have a script that reads a text file and sends out an email. In the last week, the email sent out 15-20 times when it should only be sent out once. It doesn't happen every day.
I'm currently running macro schedule 11.1.23 and was recently upgraded to windows 7, so I'm not sure if that is the issue. The script is below. Any help would be greatly appreciated.
VBStart
Function CreateEmail(strRecipient, strSubject, strBody)
'Create OL App object
Set objOLApp = CreateObject("Outlook.Application")
If objOLApp is nothing then
MsgBox "Could not create OL App. Shutting Down"
Exit Function
End If
'Create a new mail item
Set objMsg = objOLApp.CreateItem(0)
If objMsg is nothing then
MsgBox "Could not create Mail Item. Shutting Down"
Exit Function
End If
'Set basic message parameters
objMsg.To = strRecipient
objMsg.Subject = strSubject
objMsg.Body = strBody
'Send the message
objMsg.Send
'Free up the space
Set objOLApp = Nothing
Set objMsg = Nothing
CreateEmail = "Success"
End Function
VBEnd
Run Program>C:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe
Let>strTo=salesrecipients
vbe>date()-1,mydate
Let>strSubj=Sales: %mydate%
Let>body=
Let>k=1
Label>start
ReadLn>C:\DailySales.txt,k,line
If>line=##EOF##,finish
Let>body=%body%%CRLF%%line%
Let>k=k+1
Goto>start
Label>finish
Issue with scheduled macro - running more than once
Moderators: JRL, Dorian (MJT support)
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA