Peter.Stevens2
Board Regular
- Joined
- Sep 16, 2008
- Messages
- 56
Hi <?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I am using a macro to send several emails from outlook 2000.<o></o>
<o></o>
The problem is that whilst sending the emails most of the time the sendkeys work but other times the windows remain open in the background. I am guessing its a timing issue : by this I mean that when the first email is sent it has not quite finished before then next one tries to send. I have tried varying the waittime before sends but seems temperamental. <o></o>
<o></o>
Question: Is there a way to check createobject has completed its spawn process before continuing ?. <o></o>
<o></o>
It would be great to use .recipients.add but this has the effect if getting that annoying Outlook Security Warning message that asks the user to tick Allow external macro intrusions and send then press send - which is undesirable.<o></o>
<o></o>
Question : Is there a way of placing two email addresses in the .To field i.e. .To = (testemail1@rolls-royce.com; testemail2@rolls-royce.com)<o></o>
If so I would not need to send twice.<o></o>
<o></o>
I am using a macro to send several emails from outlook 2000.<o></o>
<o></o>
The problem is that whilst sending the emails most of the time the sendkeys work but other times the windows remain open in the background. I am guessing its a timing issue : by this I mean that when the first email is sent it has not quite finished before then next one tries to send. I have tried varying the waittime before sends but seems temperamental. <o></o>
<o></o>
Question: Is there a way to check createobject has completed its spawn process before continuing ?. <o></o>
<o></o>
It would be great to use .recipients.add but this has the effect if getting that annoying Outlook Security Warning message that asks the user to tick Allow external macro intrusions and send then press send - which is undesirable.<o></o>
<o></o>
Question : Is there a way of placing two email addresses in the .To field i.e. .To = (testemail1@rolls-royce.com; testemail2@rolls-royce.com)<o></o>
If so I would not need to send twice.<o></o>
Code:
Set myOlApp = CreateObject("Outlook.Application")
Set myMail = myOlApp.CreateItem(olMailItem)
If Application.Wait(Now + TimeValue("0:00:01")) Then
With myMail
.Display
.To = email_recipient_1
.Subject = "Test 1"
.Body = mailBody
End With
SendKeys ("^~")
End If
Set myOlApp = CreateObject("Outlook.Application") 'Create outlook
Set myMail = myOlApp.CreateItem(olMailItem) 'create mail item
If Application.Wait(Now + TimeValue("0:00:02")) Then
With myMail
.Display
.To = email_recipient_2
.Subject = "test"
.Body = mailBody
End With
SendKeys ("^~")
End If