09-08-2012, 12:23 AM
Currently I use something like this to send my email (as it has been succesfull for quite some time)
Rescently i noticed that my emails are not being sent until I open Outlook.
So I added:
now i get 2 emails sent. If Outlook is open, i end up having two Outlook apps open.
Should not my original code just send my email without having to open Outlook?
Code:
Set oUtlookApp = CreateObject("Outlook.Application")
Set newMail = oUtlookApp.CreateItem(0)
newMail.Subject = strSubject
newMail.Body = strMessageBody
newMail.To = strMailID_TO
newMail.CC = strMailID_CC
newMail.BCC = strMailID_BCC
If SendResultsInEmailMessage = 1 Then
If strAttachment <> "" Then
WScript.Sleep (3000) 'Wait(3)
newMail.Attachments.Add (strAttachment)
Else
Exit Function
End If
On Error Resume Next
End If
WScript.Sleep (3000) 'Wait(3)
newMail.Display 'Displays e-mail message window
WScript.Sleep (3000) 'Wait(3)
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing
Rescently i noticed that my emails are not being sent until I open Outlook.
So I added:
Code:
systemUtil.Run "OUTLOOK.EXE"
now i get 2 emails sent. If Outlook is open, i end up having two Outlook apps open.
Should not my original code just send my email without having to open Outlook?